Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 199378 - #! does not seem to pass along arguments as expected
Summary: #! does not seem to pass along arguments as expected
Status: VERIFIED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers
URL:
Whiteboard:
Keywords:
: 202546 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-11-16 17:15 UTC by cyril mougel
Modified: 2007-12-17 19:11 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
patch for sow bin works (hoe-sow.patch,201 bytes, patch)
2007-11-16 18:40 UTC, cyril mougel
Details | Diff
emerge --info output (emerge-info.txt,9.32 KB, text/plain)
2007-11-17 10:51 UTC, Hans de Graaff
Details

Note You need to log in before you can comment on or make changes to this bug.
Description cyril mougel 2007-11-16 17:15:10 UTC
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.
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2007-11-16 17:52:07 UTC
Which ebuild version is this about? Also, can you attach the patch?
Comment 2 cyril mougel 2007-11-16 18:40:01 UTC
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.
Comment 3 cyril mougel 2007-11-16 18:40:36 UTC
Created attachment 136101 [details, diff]
patch for sow bin works
Comment 4 Hans de Graaff gentoo-dev Security 2007-11-17 10:03:13 UTC
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?
Comment 5 Hans de Graaff gentoo-dev Security 2007-11-17 10:50:54 UTC
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. 
Comment 6 Hans de Graaff gentoo-dev Security 2007-11-17 10:51:43 UTC
Created attachment 136133 [details]
emerge --info output

My emerge --info output.
Comment 7 SpanKY gentoo-dev 2007-11-18 02:29:08 UTC
has nothing to do with /usr/bin/env

the kernel parses #! and passes those to userspace
Comment 8 Duane Griffin 2007-11-18 12:07:03 UTC
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
Comment 9 Hans de Graaff gentoo-dev Security 2007-11-18 13:42:20 UTC
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.
Comment 10 Jakub Moc (RETIRED) gentoo-dev 2007-12-17 07:05:08 UTC
*** Bug 202546 has been marked as a duplicate of this bug. ***
Comment 11 Hans de Graaff gentoo-dev Security 2007-12-17 19:11:17 UTC
I've asked for rubygems-0.9.4-r2 to be stabilized in bug 202608 so that the fix will become more widely available.