From: Caleb Clausen on
On 7/28/10, Roger Pack <rogerpack2005(a)gmail.com> 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.

From: Joel VanderWerf on
Caleb Clausen wrote:
> On 7/28/10, Roger Pack <rogerpack2005(a)gmail.com> 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.

From: Hassan Schroeder on
On Wed, Jul 28, 2010 at 3:14 PM, Joel VanderWerf
<joelvanderwerf(a)gmail.com> wrote:

> That's the behavior in both zsh and bash.

Ah, good detectorizing :-) and that explains the JRuby "issue" -- even
though $JRUBY_HOME/bin/jruby is a bash script, it contains this line:

JRUBY_SHELL=/bin/sh

so apparently no '_' environment variable will be forthcoming.

Ya learn something every day!
--
Hassan Schroeder ------------------------ hassan.schroeder(a)gmail.com
twitter: @hassan