Running Ruby 1.8.4 on Linux

This problem seems to exist with the system() function but also has the
same problem with IO#popen. Seems the working directory of a subshell
can be affected by the command being executed? In the first call to
popen, I'm just executing "env". In the second, I'm calling "env;"
(with a semicolon. I encountered this because some commands I was
calling with system() were unable to find files that should have been
in the directory that I chdir'd to.

Program and Output below.

Thanks,
Charlton

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