mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
8be410f065
have same fileno. * eval.c (rb_load): raise LocaJumpError if unexpected local jumps appear during load. * ext/socket/socket.c (bsock_close_read): don't call rb_thread_fd_close(); it's supposed to be called by io_io_close(). * ext/socket/socket.c (bsock_close_read): do not modify f and f2. * ext/socket/socket.c (bsock_close_write): ditto. * ext/socket/socket.c (sock_new): avoid dup(2) on sockets. * parse.y (primary): preserve and clear in_single and in_def using stack to prevent nested method errors in singleton class bodies. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
32 lines
481 B
Ruby
32 lines
481 B
Ruby
# importenv.rb -- imports environment variables as global variables, Perlish ;(
|
|
#
|
|
# 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
|
|
$#{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
|
|
|