From: Ryan Davis Date: 2007-02-11T19:50:51+09:00 Subject: Re: ENV['COLUMNS'] On Feb 10, 2007, at 3:25 AM, pedro mg wrote: > Hi, > > in irb I can have access to ENV['COLUMNS'] for the # of columns in > the shell, and works fine. > But inside a script (ruby script.rb), I can't have access to that > hash key and value. > I've done a: > > puts ENV.to_a > > and i can not see both COLUMNS and LINES > What would be the problem ? COLUMNS isn't exported. You shouldn't be able to see it within your irb session without exporting it or doing something else special. % echo $COLUMNS 80 % ruby -e 'p ENV.keys.grep(/COL/)' [] % irb >> p ENV.keys.grep(/COL/) [] => nil >> ^d % export COLUMNS % ruby -e 'p ENV.keys.grep(/COL/)' ["COLUMNS"] % irb >> p ENV.keys.grep(/COL/) ["COLUMNS"] => nil >> ^d I suggest you use stty instead. % ruby -e 'p `stty size`.scan(/\d+/).map { |s| s.to_i }' [24, 80]