From: Nobuyoshi Nakada Date: 2006-12-21T09:55:01+09:00 Subject: Re: Kernel#system bug? Hi, At Thu, 21 Dec 2006 06:45:06 +0900, Charlton wrote in [ruby-talk:230639]: > Program: > > Dir.mkdir("bug") if !FileTest.exists?("bug") > File.open("bug/bugfile", "w") { |file| > file << "Bug!" > } > Dir.chdir("bug") > > puts "without semi-colon" > IO.popen("env").readlines.each do |entry| > puts entry if entry =~ /PWD/ > end > > puts "with semi-colon" > IO.popen("env;").readlines.each do |entry| > puts entry if entry =~ /PWD/ > end > > Output: > > without semi-colon > PWD=/user/blah/tests/ruby > with semi-colon > PWD=/user/blah/tests/ruby/bug It is natural result. PWD is not set by OS automatically, but set by sh. You should use getcwd() in C or Dir.pwd in ruby instead of relying on $PWD. -- Nobu Nakada