Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

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 drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2019-11-23 01:44 GMT
Find Nodes?
    Voting Booth?
    Strict and warnings: which comes first?

    Results (113 votes). Check out past polls.