From: Steven Lumos Date: 2007-02-14T11:18:02+09:00 Subject: Re: ENV['COLUMNS'] Ryan Davis writes: > 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 $ echo $COLUMNS 80 $ ruby -e 'p ENV["COLUMNS"]' nil $ irb >> ENV["COLUMNS"] => "80" $ irb --noreadline >> ENV["COLUMNS"] => nil >> ^D $ cd /src/devel/readline/readline-4.2 $ grep setenv *.c shell.c: setenv ("LINES", b, 1); shell.c: setenv ("COLUMNS", b, 1); Most people probably don't consider using irb with readline "special". It's probably only in your shell due to readline, libedit, or similar in the first place. $ /bin/ksh $ echo $COLUMNS $ Steve