From: Joel VanderWerf Date: 2010-07-29T07:14:59+09:00 Subject: Re: Which Ruby is in use? Caleb Clausen wrote: > On 7/28/10, Roger Pack wrote: >>> I haven't checked yet whether there's a bug filed against JRuby >>> for the lack of support for ENV['_'], which obviously wins the >>> minimalist contest :-) >> ENV['_'] doesn't seem to work for me on windows at all: >> >>>> ENV['_'] >> => nil >> >> Thought it might still be a bug in jruby that it not have one under >> linux, I'm not entirely sure. > > I just did a quick check, and I'm not seeing anywhere in the ruby > source where it sets an envvar named _. Perhaps this envvar is a > feature of bash or linux or something other than ruby. > Yeah, I think it's just a shell feature: $ ruby -e 'p ENV["_"]' "/usr/local/bin/ruby" $ env ruby -e 'p ENV["_"]' "/usr/bin/env" That's the behavior in both zsh and bash. Found this in some bash docs: > The underscore variable is set at shell startup and contains the > absolute file name of the shell or script being executed as passed in > the argument list. Subsequently, it expands to the last argument to > the previous command, after expansion. It is also set to the full > pathname of each command executed and placed in the environment > exported to that command. When checking mail, this parameter holds > the name of the mail file.