From: Lloyd Zusman Date: 2007-02-10T22:56:35+09:00 Subject: Re: ENV['COLUMNS'] Brian Candler writes: > On Sat, Feb 10, 2007 at 08:25:09PM +0900, pedro mg wrote: >> 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 ? > > Nothing to do with ruby... > > brian@mappit:~$ echo $COLUMNS > 80 > brian@mappit:~$ printenv | grep COLUMNS > brian@mappit:~$ > > This is a shell-internal variable, and not exported by default to processes > launched from the shell. But it can be if you wish: Well, if that were the case, the variable wouldn't be visible within irb, either. Since it is, then it must be an exported environment variable and not just shell internal. I think that the problem has to do with how script.rb is being invoked. Is it started from something other than a terminal session? ... perhaps via a cron job or a startup daemon? If so, then LINES and COLUMNS would not normally be set, since those environment variables are usually initialized and exported only within an interactive shell. > brian@mappit:~$ export COLUMNS > brian@mappit:~$ printenv | grep 80 > COLUMNS=80 > brian@mappit:~$ > > Brian. -- Lloyd Zusman ljz@asfast.com God bless you.