Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^3: shebang anomaly

by huck (Parson)
on Apr 19, 2018 at 00:00 UTC ( #1213144=note: print w/replies, xml ) Need Help??

in reply to Re^2: shebang anomaly
in thread shebang anomaly

The shebang line has never been specified as part of POSIX, SUS, LSB or any other specification. AFAIK, it hasn't even been properly documented.
There is a rough consensus about what it does: take everything between the ! and the \n and exec it. The assumption is that everything between the ! and the \n is a full absolute path to the interpreter. There is no consensus about what happens if it contains whitespace.

1 Some operating systems simply treat the entire thing as the path. After all, in most operating systems, whitespace or dashes are legal in a path.
2 Some operating systems split at whitespace and treat the first part as the path to the interpreter and the rest as individual arguments.
3 Some operating systems split at the first whitespace and treat the front part as the path to the interpeter and the rest as a single argument (which is what you are seeing).
4 Some even don't support shebang lines at all.

Thankfully, 1. and 4. seem to have died out, but 3. is pretty widespread, so you simply cannot rely on being able to pass more than one argument.

Replies are listed 'Best First'.
Re^4: shebang anomaly
by QM (Parson) on Apr 19, 2018 at 09:18 UTC
    Option 3 is much like MS DOS and its successors: make every program parse its own command line.

    Given that quoting in DOS is so difficult, most people don't try to write perl one-liners there. (Granted, it's hard enough in *shell sometimes.)

    Quantum Mechanics: The dreams stuff is made of

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1213144]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (13)
As of 2018-12-10 20:47 GMT
Find Nodes?
    Voting Booth?
    How many stories does it take before you've heard them all?

    Results (52 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!