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