From: Jeffrey Schwab Date: 2006-10-06T02:50:08+09:00 Subject: Re: ENV shows partial environment only ara.t.howard@noaa.gov wrote: > On Thu, 5 Oct 2006, Eero Saynatkari wrote: > >> Hi! >> >> It seems that Ruby is not picking up the complete environment >> to be accessible through ENV--and I seem to recall this is by >> design. Cursory poking-around in {hash,ruby,eval}.c did not >> reveal anything particularly enlightening. Could someone shed >> light on this if it indeed is done intentionally by Ruby and >> not due to some strangeness in the C env functions? >> >> An example session: >> >> 18:28:43 ruerue@yawn > ruby -v >> ruby 1.8.5 (2006-08-25) [amd64-freebsd6] >> >> 18:28:51 ruerue@yawn > set | ruby -e 'p ARGF.readlines.map {|l| >> l.split("=").first if l =~ /^[A-Z]/}.compact' >> >> ["BASH", "BASH_ARGC", "BASH_ARGV", "BASH_LINENO", "BASH_SOURCE", >> "BASH_VERSINFO", "BASH_VERSION", "BLOCKSIZE", "COLUMNS", "DIRSTACK", >> "DISPLAY", "EDITOR", "EUID", "FTP_PASSIVE_MODE", "GROUPS", "HISTFILE", >> "HISTFILESIZE", "HISTSIZE", "HOME", "HOSTNAME", "HOSTTYPE", "IFS", >> "LINES", "LOGNAME", "MACHTYPE", "MAIL", "MAILCHECK", "OPTERR", "OPTIND", >> "OSTYPE", "PATH", "PIPESTATUS", "PPID", "PR_BROWN", "PR_CLEAR", >> "PR_LTGREY", "PS1", "PS2", "PS4", "PWD", "RS_EMAIL", "RS_NAME", "SHELL", >> "SHELLOPTS", "SHLVL", "TERM", "TERMCAP", "UID", "USER", "WINDOWID", >> "XAUTHORITY", "XTERM_SHELL", "XTERM_VERSION"] >> >> 18:28:54 ruerue@yawn > ruby -e 'p ENV.keys' >> >> ["SHELL", "TERM", "WINDOWID", "XTERM_SHELL", "RS_NAME", "USER", >> "TERMCAP", "FTP_PASSIVE_MODE", "PATH", "MAIL", "BLOCKSIZE", "PWD", >> "EDITOR", "XTERM_VERSION", "HOME", "SHLVL", "LOGNAME", "RS_EMAIL", >> "DISPLAY", "XAUTHORITY", "_"] > > it's been a while, but are you confusing shell vars with env vars? i think > 'set' only reports the former: > > harp:~ > export FOO=ENV_BAR > > harp:~ > set FOO=SHELL_BAR > > harp:~ > sh > > harp:~ > echo $FOO > ENV_BAR You're using Bash/ksh syntax, but just so you know, the greater-than symbol (>) is usually reserved to mean csh or tcsh. $ is the canonical non-root bash prompt. Switching them up makes examples like this one a little confusing, and can be frustrating when you have to use someone else's machine for a second (e.g. to provide tech support through a VNC session) and some commands fail for no apparent reason.