1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib/importenv.rb
usa b0c9219402 * lib/{cgi-lib,getopts,importenv}.rb: check caller[0] because when
required by -r option it's nil.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@17572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-25 09:56:11 +00:00

33 lines
606 B
Ruby

# importenv.rb -- imports environment variables as global variables, Perlish ;(
#
# Usage:
#
# require 'importenv'
# p $USER
# $USER = "matz"
# p ENV["USER"]
warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')+':' if caller[0]} importenv is deprecated after Ruby 1.8.1 (no replacement)"
for k,v in ENV
next unless /^[a-zA-Z][_a-zA-Z0-9]*/ =~ k
eval <<EOS
$#{k} = v
trace_var "$#{k}", proc{|v|
ENV[%q!#{k}!] = v
$#{k} = v
if v == nil
untrace_var "$#{k}"
end
}
EOS
end
if __FILE__ == $0
p $TERM
$TERM = nil
p $TERM
p ENV["TERM"]
$TERM = "foo"
p ENV["TERM"]
end