~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to lib/importenv.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
10
warn "Warning:#{caller[0].sub(/:in `.*'\z/, '')}: importenv is deprecated after Ruby 1.8.1 (no replacement)"
 
11
 
 
12
for 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
  }
 
23
EOS
 
24
end
 
25
 
 
26
if __FILE__ == $0
 
27
  p $TERM
 
28
  $TERM = nil
 
29
  p $TERM
 
30
  p ENV["TERM"]
 
31
  $TERM = "foo"
 
32
  p ENV["TERM"]
 
33
end