Skip to contentSkip to conversation

#! incompatible -- binfmt_script.c broken?

PATCH Petr Vandrovec 5 participants 12 messages Dec 4, 2002 – Dec 10, 2002 1 message not in the archive

lore
Share & tools
lore
#0 lore raw
Quoted 8 lines · On 4 Dec 02 at 18:52, [email protected] wrote:
Quoted 2 lines

single argument but strips trailing whitespace. NetBSD does the same as Linux but passes trailing whitespace as part of the argument.

NetBSD is also broken, in that case. Everything I ever used that supported #! except linux worked sensibly. I even wrote myself a patch, which still applied to 2.4 fairly recently. It's not perfect (has a fixed number of args to avoid allocating from the heap, would be easy to change), but it's functional.

Without adding support to parse " and ' it is unacceptable. I have dozens of scripts which use argument with spaces inside... Also all references I was able to found talks about "single optional argument" (SCO, AIX)... Try running script containing

#! /bin/ls a b c

on your favorite system. If it will report
'/bin/ls: a b c: No such file or directory', or
'ls: 0653-341 The file a b c does not exist', system does not split argument on spaces. If it will talk about 'a' not found, it splits them on spaces.

And because of I was not able to find anything in POSIX which would say that we should do split on spaces (not that I found that we should not), I vote for leaving current behavior in Linux, and fixing perl manpage (and eventually FreeBSD, if anyone is interested) instead.
Petr Vandrovec [email protected]

#1 lore raw
Followup to:  <[email protected]>
By author:    "Petr Vandrovec" <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 6 lines

And because of I was not able to find anything in POSIX which would say that we should do split on spaces (not that I found that we should not), I vote for leaving current behavior in Linux, and fixing perl manpage (and eventually FreeBSD, if anyone is interested) instead.

Classic catch-22: POSIX won't standardize it because of lack of consistency between UNIX implementations, although everyone pretty much agrees it would be a desirable feature to add to the standard.

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt	<[email protected]>
#2 lore raw
In reply to Petr Vandrovec
Quoted 4 lines · Petr Vandrovec

And because of I was not able to find anything in POSIX which would say that we should do split on spaces (not that I found that we should not), I vote for leaving current behavior in Linux, and fixing perl manpage (and eventually FreeBSD, if anyone is interested) instead.

Indeed.

Whatever linux does, that usage remains massively unportable, so the man page should be changed regardless.

-Miles

Signature · 2 lines
A zen-buddhist walked into a pizza shop and
said, "Make me one with everything."

A message that is not in the archive (sent off-list or not yet received): [email protected]

#4 lore raw

Hi!

Quoted 9 lines
Quoted 5 lines

And because of I was not able to find anything in POSIX which would say that we should do split on spaces (not that I found that we should not), I vote for leaving current behavior in Linux, and fixing perl manpage (and eventually FreeBSD, if anyone is interested) instead.

Classic catch-22: POSIX won't standardize it because of lack of consistency between UNIX implementations, although everyone pretty much agrees it would be a desirable feature to add to the standard.

Why can't we simply have /bin/bash_that_splits_args_itself ?
Pavel

Signature · 2 lines
				Pavel
Written on sharp zaurus, because my Velo1 broke. If you have Velo you don't need...
#5 lore raw
Quoted 4 lines · Pavel Machek

Why can't we simply have /bin/bash_that_splits_args_itself ?
Pavel

We could, but it would in practice mean doing an extra exec() for each executable. This seems undesirable.

-hpa

#6 lore raw

Hi!

Quoted 4 lines
Quoted 1 line

Why can't we simply have /bin/bash_that_splits_args_itself

We could, but it would in practice mean doing an extra exec() for each executable. This seems undesirable.

Only for executables that need argument spliting... For such scripts I guess we can get handle the overhead.

Pavel

Signature · 2 lines
Casualities in World Trade Center: ~3k dead inside the building,
cryptography in U.S.A. and free speech in Czech Republic.
#7 lore raw
Followup to:  <[email protected]>
By author:    Pavel Machek <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 11 lines

Hi!

Quoted 4 lines
Quoted 1 line

Why can't we simply have /bin/bash_that_splits_args_itself

We could, but it would in practice mean doing an extra exec() for each executable. This seems undesirable.

Only for executables that need argument spliting... For such scripts I guess we can get handle the overhead.

We probably can, but a better question is really: what are the semantics that users expect? Given that Unices are by and large inconsistent, we should pick the behaviour that makes sense to the most people. I suspect that most people would expect whitespace partition.

-hpa

Signature · 3 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt	<[email protected]>
#8 lore raw
Quoted 5 lines · H. Peter Anvin

We probably can, but a better question is really: what are the semantics that users expect? Given that Unices are by and large inconsistent, we should pick the behaviour that makes sense to the most people. I suspect that most people would expect whitespace partition.

I'd rather keep it as is. We should be doing IFS partition with quoting, UTF-8 awareness according to locale and locale specific rules on whitespace. That says "userspace" all over it.

We can keep this out of kernel which is good - though it reminds me we do need to fix backspace/delete in the tty layer on a unicode configured tty to do the right thing. (Extra ioctls for unicode delete characters are a longer less funny subject though)

#9 lore raw
Quoted 5 lines · Alan Cox

I'd rather keep it as is. We should be doing IFS partition with quoting, UTF-8 awareness according to locale and locale specific rules on whitespace. That says "userspace" all over it.

Actually, I would argue we definitely should *not*.

-hpa

#10 lore raw
Quoted 8 lines · H. Peter Anvin
Quoted 5 lines · Alan Cox

I'd rather keep it as is. We should be doing IFS partition with quoting, UTF-8 awareness according to locale and locale specific rules on whitespace. That says "userspace" all over it.

Actually, I would argue we definitely should *not*.

I don't see how you can do otherwise. The very definition of "whitespace" is locale specific. Throwing it at the target as one string lets the kernel stay out of locales, languages, policy and other parsing horrors. Splitting it has to be done properly or its a non reversible operation and tools can't correct the kernel screwups

#11 lore raw
Quoted 7 lines · Alan Cox

I don't see how you can do otherwise. The very definition of "whitespace" is locale specific. Throwing it at the target as one string lets the kernel stay out of locales, languages, policy and other parsing horrors. Splitting it has to be done properly or its a non reversible operation and tools can't correct the kernel screwups

In theory I agree with you. I'm just wondering what is the most practical.

-hpa

#12 lore raw
In reply to H. Peter Anvin

Hi!

Quoted 9 lines
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Why can't we simply have /bin/bash_that_splits_args_itself

We could, but it would in practice mean doing an extra exec() for each executable. This seems undesirable.

Only for executables that need argument spliting... For such scripts I guess we can get handle the overhead.

Quoted 5 lines

We probably can, but a better question is really: what are the semantics that users expect? Given that Unices are by and large inconsistent, we should pick the behaviour that makes sense to the most people. I suspect that most people would expect whitespace partition.

Most people would also expect " and ' to work, and $FOO to work :-(. So I believe keeping it simple is right.
Pavel

Signature · 2 lines
Worst form of spam? Adding advertisment signatures ala sourceforge.net.
What goes next? Inserting advertisment *into* email?