source: extensions/gsdl-video/trunk/installed/cmdline/lib/ruby/1.8/importenv.rb@ 18425

Last change on this file since 18425 was 18425, checked in by davidb, 15 years ago

Video extension to Greenstone

File size: 590 bytes
Line 
1# importenv.rb -- imports environment variables as global variables, Perlish ;(
2#
3# Usage:
4#
5# require 'importenv'
6# p $USER
7# $USER = "matz"
8# p ENV["USER"]
9
10warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: importenv is deprecated after Ruby 1.8.1 (no replacement)"
11
12for k,v in ENV
13 next unless /^[a-zA-Z][_a-zA-Z0-9]*/ =~ k
14 eval <<EOS
15 $#{k} = v
16 trace_var "$#{k}", proc{|v|
17 ENV[%q!#{k}!] = v
18 $#{k} = v
19 if v == nil
20 untrace_var "$#{k}"
21 end
22 }
23EOS
24end
25
26if __FILE__ == $0
27 p $TERM
28 $TERM = nil
29 p $TERM
30 p ENV["TERM"]
31 $TERM = "foo"
32 p ENV["TERM"]
33end
Note: See TracBrowser for help on using the repository browser.