[#35446] [Ruby 1.9 - Bug #4477][Open] Kernel:exec and backtick (`) don't work for certain system commands — Joachim Wuttke <j.wuttke@...>

10 messages 2011/03/07

[#35476] [Ruby 1.9 - Bug #4489][Open] [PATCH] Encodings with /-(unix|dos|mac)\Z/ — "James M. Lawrence" <quixoticsycophant@...>

20 messages 2011/03/10

[#35552] [Ruby 1.9 - Feature #4523][Open] Kernel#require to return the path of the loaded file — Alex Young <alex@...>

14 messages 2011/03/24

[#35565] [Ruby 1.9 - Feature #4531][Open] [PATCH 0/7] use poll() instead of select() in certain cases — Eric Wong <normalperson@...>

33 messages 2011/03/28

[#35566] [Ruby 1.9 - Feature #4532][Open] [PATCH] add IO#pread and IO#pwrite methods — Eric Wong <normalperson@...>

12 messages 2011/03/28

[#35586] [Ruby 1.9 - Feature #4538][Open] [PATCH (cleanup)] avoid unnecessary select() calls before doing I/O — Eric Wong <normalperson@...>

9 messages 2011/03/29

[ruby-core:35452] [Ruby 1.9 - Feature #4477] Kernel:exec and backtick (`) don't work for certain system commands

From: Joachim Wuttke <j.wuttke@...>
Date: 2011-03-07 10:40:26 UTC
List: ruby-core #35452
Issue #4477 has been updated by Joachim Wuttke.


Sorry, Shota, I do not understand why you recategorized this issue as a Feature.

The current behaviour of `<cmd>` contradicts what the documentation says, and it offends common sense. In my understanding, this is clearly a Bug.
----------------------------------------
Feature #4477: Kernel:exec and backtick (`) don't work for certain system commands
http://redmine.ruby-lang.org/issues/4477

Author: Joachim Wuttke
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


From documentation and common sense, I would expect that Kernel:exec and backtick (`) work for _all_ kind of system commands. This is currently not the case.

~$ cat test1
echo success
~$ cat test2
#!/bin/sh
echo success
~$ chmod a+x test?
~$ ruby1.8 -e 'p `test1`'
-e:1: command not found: test1
""
~$ ruby1.9 -e 'p `test1`'
-e:1:in ``': Exec format error - test1 (Errno::ENOEXEC)
        from -e:1:in `<main>'
~$ ruby1.8 -e 'p `test2`'
"success\n"
~$ ruby1.9 -e 'p `test2`'
"success\n"

This problem has been reported before (#3856: strange Kernel#exec behavior with bash's source command). As a workaround, it has been suggested to append a semikolon to the system command:

~$ ruby1.8 -e 'p `test1;`'
"success\n"
~$ ruby1.9 -e 'p `test1;`'
"success\n"

The report #3856 has been closed with the decision "not a bug".

This I cannot accept. For many years, I got used to run system commands through `<cmd>`. When it failed, I spent painfully long time to search for a bug in my Ruby code and in the system command before I realized the problem was due to an unexpected restriction of Ruby's exec/backtick.


-- 
http://redmine.ruby-lang.org

In This Thread