[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: ENV shows partial environment only

Gennady Bystritsky

10/5/2006 3:45:00 AM

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.


1 Answer

Eero Saynatkari

10/5/2006 7:00:00 AM

0

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

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

Thanks to Mike and Logan also.