Bug 199378 - #! does not seem to pass along arguments as expected
|
Bug#:
199378
|
Product: Gentoo Linux
|
Version: unspecified
|
Platform: All
|
|
OS/Version: Linux
|
Status: CLOSED
|
Severity: normal
|
Priority: P2
|
|
Resolution: INVALID
|
Assigned To: kernel@gentoo.org
|
Reported By: cyril.mougel@gmail.com
|
|
Component: Core system
|
|
|
URL:
|
|
Summary: #! does not seem to pass along arguments as expected
|
|
Keywords:
|
|
Status Whiteboard:
|
|
Opened: 2007-11-16 17:15 0000
|
When a want use hoe with the sow command. I have an error :
hello-18:08:30:~/$ sow whotowho
/usr/bin/env: ruby -ws: Aucun fichier ou répertoire de ce type
The error message in english is : No File or directory of this type
If I patch the file /usr/bin/sow and I delete the -ws in first line, I have no
error after.
Reproducible: Always
Steps to Reproduce:
1. sow project
2.
3.
Which ebuild version is this about? Also, can you attach the patch?
Sorry for my forget.
The version where I see this issue is the version 1.2.2.
I had made a patch and I attach it.
As far as I can tell from the documentation this is a bug in /usr/bin/env
(which would be a bit weird). Could you provide emerge --info and the version
of coreutils on your system?
According to the documentation, /usr/bin/env should handle the case where a
command and args are given. This works fine in a shell, e.g. "env ls -l" works
as expected, executing 'ls' with '-l' as the argument.
However, when this is done in a shebang file like this:
#!/usr/bin/env ls -l
then env tries to execute 'ls -l' as a command, which obviously fails. I don't
think that env itself is to blame here, but just gets the rest of the line as a
single argument instead of multiple arguments.
has nothing to do with /usr/bin/env
the kernel parses #! and passes those to userspace
This is not a bug. It is the intended, albeit surprising, behaviour. On linux
shebang invocations of an interpreter will be passed a maximum of one argument.
Space separated words will be passed as one string. It is one of those lovable
little *nix quirks that trips everyone up the first time they come across it.
From "man execve":
"The semantics of the optional-arg argument of an interpreter script vary
across implementations. On Linux, the entire string following the interpreter
name is passed as a single argument to the interpreter, and this string can
include white space. However, behavior differs on some other systems. Some
systems use the first white space to terminate optional-arg. On some systems,
an interpreter script can have multiple arguments, and white spaces in
optional-arg are used to delimit the arguments."
There is a rather good and comprehensive discussion of the exact semantics of
shebang invocations here:
http://homepages.cwi.nl/~aeb/std/hashexclam-1.html
Re-opening because the problem from the original bug reporter it not solved.
There are actually a number of bugs for this upstream:
http://rubyforge.org/search/?type_of_search=artifact&group_id=1513&atid=5921&words=sow&Search=Search
In fact, one of these bugs refers to a fix for this in rubygems. rubygems
should rewrite "/usr/bin/env ruby" interpreters on installation to use the
local path, ie. /usr/bin/ruby, but this was broken.
dev-ruby/rubygems-0.9.4-r2 should fix this. To confirm, emerge this version of
rubygems first, and then re-emerge hoe.
*** Bug 202546 has been marked as a duplicate of this bug. ***
I've asked for rubygems-0.9.4-r2 to be stabilized in bug 202608 so that the fix
will become more widely available.