lib/inch/cli.rb in inch-0.5.0.rc10 vs lib/inch/cli.rb in inch-0.5.0.rc11
- old
+ new
@@ -8,12 +8,16 @@
# Returns the columns of the terminal window
# (defaults to 80)
# @param default [Fixnum] default value for columns
# @return [Fixnum]
def get_term_columns(default = 80)
- str = `stty size`
- rows_cols = str.split(' ').map(&:to_i)
- rows_cols[1] || default
+ str = `stty size 2>&1`
+ if str =~ /Invalid argument/
+ default
+ else
+ rows_cols = str.split(' ').map(&:to_i)
+ rows_cols[1] || default
+ end
rescue
default
end
end
COLUMNS = get_term_columns