ENV shows partial environment only

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'

Command 'set' is a shell's built-in, besides environment variables it
shows also the shell's internal ones that happened to follow the same
syntax. Those internal ones are not inherited by a spawned process,
unless exported, it which case that are placed in the environment. On
the other hand, 'env' shows just environment variables, exactly same
thing will show up when you do this in Ruby:

p *ENV

Hope it helps,
Gennady.

Yep, clears that part, thanks--now I need to figure out WHY some things
are not getting propagated properly :slight_smile:

Thanks to Mike and Logan also.

ยทยทยท

On 2006.10.05 12:44, Gennady Bystritsky wrote:

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'

Command 'set' is a shell's built-in, besides environment variables it
shows also the shell's internal ones that happened to follow the same
syntax. Those internal ones are not inherited by a spawned process,
unless exported, it which case that are placed in the environment. On
the other hand, 'env' shows just environment variables, exactly same
thing will show up when you do this in Ruby:

p *ENV