From: "M. Edward (Ed) Borasky" Date: 2006-07-31T14:10:25+09:00 Subject: Re: Environment variables with empty value missing from ENV? M. Edward (Ed) Borasky wrote: > Clifford Heath wrote: >> Under Windows XP (using cygwin's bash, but native Ruby), I >> found the following six-legged feature: >> >> $ ruby -v >> ruby 1.8.2 (2004-12-25) [i386-mswin32] > Have you tried this with Ruby 1.8.4? What does "which ruby" say? > >> $ unset FOO; env|grep FOO; ruby -e 'p ENV["FOO"]' >> nil >> $ FOO= env |grep FOO >> FOO= > Is this legitimate? I've never seen anyone use this construct ("FOO= ") > What happens when you do FOO='' ? >> $ FOO= ruby -e 'p ENV["FOO"]' >> nil > What does ruby -e 'p "" ' do? >> $ FOO=xyz ruby -e 'p ENV["FOO"]' >> xyz >> $ >> >> The problem is that ENV doesn't contain the key FOO in >> the 2nd case, where the value is zero-length. >> >> What possible justification could there be for this behaviour? > I'm not sure ... is this construct useful to you in some way? Setting > an environment variable to an empty string and reading it in Ruby? > >> >> Clifford Heath. >> >> > > > On Gentoo Linux: znmeb@DreamGate ~ $ export FOO= znmeb@DreamGate ~ $ set|grep FOO FOO= _=FOO znmeb@DreamGate ~ $ export FOO="" znmeb@DreamGate ~ $ set|grep FOO FOO= _=FOO znmeb@DreamGate ~ $ which ruby /usr/bin/ruby znmeb@DreamGate ~ $ ruby -v ruby 1.8.5 (2006-06-22) [i686-linux] znmeb@DreamGate ~ $ ruby -e 'p ""' "" znmeb@DreamGate ~ $ ruby -e 'p ENV["FOO"]' "" znmeb@DreamGate ~ $ bash --version GNU bash, version 3.1.17(1)-release (i686-pc-linux-gnu) Copyright (C) 2005 Free Software Foundation, Inc. znmeb@DreamGate ~ $ Happy to help ... at least it works the way I expected it to work on Linux with Ruby 1.8.5 (pre something, IIRC). I still don't see how it's useful, though. :)