Using backquotes to run commands with shell redirects sometimes passes the
redirects to the called program
----------------------------------------------------------------------------------------------------------
Key: JRUBY-1557
URL: http://jira.codehaus.org/browse/JRUBY-1557
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.1b1, JRuby 1.0.2, JRuby 1.0.1, JRuby 1.0.0
Environment: Mac OS X 10.4.10 with Java 1.5, Linux with IBM Java 1.4.2
Reporter: Matt Fletcher
Attachments: test_backquotes_with_shell_redirects.rb
Attached is a test case that uses backquotes to invoke a Ruby program named
'arguments.' The arguments program prints the contents of ARGV. This test case
assumes the ruby and jruby commands are on your path.
Paste of the test case:
{noformat}
require "test/unit"
class BackquotesWithShellRedirectsTest < Test::Unit::TestCase
def test_backquotes_with_redirects_pass_through_shell
assert_equal "arguments: one two", `./arguments one two 2> /dev/null`,
"wrong arguments when run straight up"
assert_equal "arguments: three four", `ruby ./arguments three four 2>
/dev/null`, "wrong arguments when run with ruby prefix"
assert_equal "arguments: five six", `jruby ./arguments five six 2>
/dev/null`, "wrong arguments when run with jruby prefix"
end
end
{noformat}
Paste of the arguments program:
{noformat}
#!/usr/bin/env ruby
print "arguments: #{ARGV.join(' ')}"
{noformat}
This test case passes in MRI. It fails in JRuby, but at different points
depending on which version of JRuby you're running. Here are some results.
JRuby 1.0, 1.0.1
{noformat}
[EMAIL PROTECTED] ~/svn/jruby_bugs $ jruby
test_backquotes_with_shell_redirects.rb
Loaded suite test_backquotes_with_shell_redirects
Started
F
Finished in 0.2 seconds.
1) Failure:
test_backquotes_with_redirects_pass_through_shell(BackquotesWithShellRedirectsTest)
[test_backquotes_with_shell_redirects.rb:6]:
wrong arguments when run with ruby prefix.
<"arguments: three four"> expected but was
<"arguments: three four 2> /dev/null">.
1 tests, 2 assertions, 1 failures, 0 errors
{noformat}
JRuby 1.0.2, 1.1b1
{noformat}
[EMAIL PROTECTED] ~/svn/jruby_bugs $ jruby
test_backquotes_with_shell_redirects.rb
Loaded suite test_backquotes_with_shell_redirects
Started
F
Finished in 0.132 seconds.
1) Failure:
test_backquotes_with_redirects_pass_through_shell(BackquotesWithShellRedirectsTest)
[test_backquotes_with_shell_redirects.rb:5]:
wrong arguments when run straight up.
<"arguments: one two"> expected but was
<"arguments: one two 2> /dev/null">.
1 tests, 1 assertions, 1 failures, 0 errors
{noformat}
This particular regression is preventing me from upgrading from JRuby 1.0 to
1.0.2. My acceptance test suite is using the first form of invocation (line 5
of the test case) to run my application, which is sensitive to the passed
arguments. I'd rather not change my code to work around incorrect behavior if I
don't have to, so I'm going to stick with 1.0 for now.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email