2000-02-23 00:23:12 -05:00
|
|
|
# importenv.rb -- imports environment variables as global variables, Perlish ;(
|
1998-01-16 07:19:09 -05:00
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# require 'importenv'
|
|
|
|
# p $USER
|
|
|
|
# $USER = "matz"
|
|
|
|
# p ENV["USER"]
|
|
|
|
|
2004-02-18 10:27:06 -05:00
|
|
|
warn "Warning: importenv is deprecated after Ruby 1.8.1 (no replacement)"
|
|
|
|
|
1998-01-16 07:19:09 -05:00
|
|
|
for k,v in ENV
|
|
|
|
next unless /^[a-zA-Z][_a-zA-Z0-9]*/ =~ k
|
|
|
|
eval <<EOS
|
2001-02-13 00:09:11 -05:00
|
|
|
$#{k} = v
|
1998-01-16 07:19:09 -05:00
|
|
|
trace_var "$#{k}", proc{|v|
|
2001-02-08 04:19:27 -05:00
|
|
|
ENV[%q!#{k}!] = v
|
|
|
|
$#{k} = v
|
1998-01-16 07:19:09 -05:00
|
|
|
if v == nil
|
|
|
|
untrace_var "$#{k}"
|
|
|
|
end
|
|
|
|
}
|
|
|
|
EOS
|
|
|
|
end
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
if __FILE__ == $0
|
|
|
|
p $TERM
|
|
|
|
$TERM = nil
|
|
|
|
p $TERM
|
|
|
|
p ENV["TERM"]
|
|
|
|
$TERM = "foo"
|
|
|
|
p ENV["TERM"]
|
|
|
|
end
|