Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^7: shebang anomaly

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


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

Why do you think this works in macOS and not Linux

Because the shell used to parse and execute the shebang line is different in each of those.

Replies are listed 'Best First'.
Re^8: shebang anomaly
by jeffenstein (Pilgrim) on Apr 23, 2018 at 15:00 UTC
    I think you want to replace "shell" with "kernel". I suppose it could be in libc, but I'm certain it's not in /bin/sh, except for cygwin.
      I think you want to replace "shell" with "kernel". I suppose it could be in libc, but I'm certain it's not in /bin/sh, except for cygwin.

      No, sorry, shells have to have a fallback mechanism if your O/S claims POSIX compatibility. See Re^2: Shebang behavior with perl. It's not in libc. But yes, usually the kernel extracts the interpreter and the argument (note: singular) from the shebang line.

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        The linked page in your other response only has this reference to the shebang line:

        The shell reads its input from a file (see sh), from the -c option or from the system() and popen() functions defined in the System Interfaces volume of POSIX.1-2017. If the first line of a file of shell commands starts with the characters "#!", the results are unspecified.

        The last I checked, /bin/sh on Solaris wasn't even POSIX compliant, so you can't count on that. So, to go back to the OP, I would say for maximum portability to write a bourne shell (/bin/sh) wrapper to run it, or give this snippet from perlrun a try to avoid a wrapper:

        #!/bin/sh #! -*-perl-*- eval 'exec perl -x -wS $0 ${1+"$@"}' if 0;
    A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2019-12-10 10:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?