Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^3: shebang anomaly

by huck (Vicar)
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

https://stackoverflow.com/posts/4304187/revisions

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.)

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2018-10-18 16:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When I need money for a bigger acquisition, I usually ...














    Results (103 votes). Check out past polls.

    Notices?