Created
May 6, 2009 05:20
-
-
Save thinkerbot/107363 to your computer and use it in GitHub Desktop.
a check of ENV inheritance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script demonstrates that ENV variables are inherited | |
# in system calls. The printout (assuming VARIABLE is not | |
# set beforehand) is: | |
# | |
# % ruby env_inheritance.rb | |
# before: | |
# reset: blue | |
# system: blue | |
# popen: blue | |
# after: blue | |
# | |
puts "before: #{ENV["VARIABLE"]}" | |
ENV["VARIABLE"] = "blue" | |
puts "reset: #{ENV["VARIABLE"]}" | |
system %q{ruby -e 'puts "system: #{ENV["VARIABLE"]}"; ENV["VARIABLE"] = "green"'} | |
IO.popen %q{ruby -e 'puts "popen: #{ENV["VARIABLE"]}"; ENV["VARIABLE"] = "green"'} do |io| | |
puts io.read | |
end | |
puts "after: #{ENV["VARIABLE"]}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment