in reply to shebang problem on openSUSE

A search on DuckDuckGo brings up some relevant results. There was some article/discussion on Perl specific resource, outside of Stack Overflow, but I cannot find or remember it.

In env perl -1, env tries to find a file to execute named perl -l. It is not found, hence the error. OTOH perl -l parses the run time options by itself so there is no problem there.

Replies are listed 'Best First'.
Re^2: shebang problem on openSUSE
by kcott (Archbishop) on Mar 24, 2018 at 05:15 UTC

    Thanks for replying.

    "A search on DuckDuckGo brings up some relevant results."

    That is, in fact, the search engine I used. Could you post the URL you used which returned the "relevant results". I seached for "shebang perl openSUSE", which ended up as this URL: https://duckduckgo.com/?q=shebang+perl+openSUSE&t=opensuse&ia=qa.

    I didn't see any results where 'perl -l' (or 'perl -w' or similar) was treated as a single filename containing a space character. As I wrote that, I thought I might try the same code as before with this shebang line:

    #!/usr/bin/env perl -w

    When run, that now produces:

    ken@ibm-laptop:~/tmp> test_shebang.pl /usr/bin/env: perl -w: No such file or directory

    I checked "man env" and subsequently, from the information it suplied, "info '(coreutils) env invocation'" and http://www.gnu.org/software/coreutils/manual/coreutils.html#env-invocation. All show an invocation of this form:

    env [option]… [name=value]… [command [args]…]

    As far as I can see, none mention anything special about the space after "command".

    I've been using shebang lines like this for over a decade. I would have posted dozens (if not hundreds) of scripts on this site using "#!/usr/bin/env perl -l" without a single complaint.

    If 'perl -l' is being interpreted as a single filename (containing a space character), that would be most unusual behaviour and I would hope there would be a way to turn it off.

    — Ken

        ++ Thanks beech, that answers my question and resolves the issue.

        The table showing different behaviours was particularly helpful. It would appear that I have mostly been using OSes that do parse all arguments separately; for instance, I've had Mac OS X at home for the last eight years and that's what I would have used, almost exclusively, for scripts I've posted on this site. I was quite unaware that wasn't the normal case: hence my surprise at the behaviour on this borrowed laptop.

        — Ken

        Thanks. That's better search criteria and produces, as you said, "some relevant results".

        — Ken

Re^2: shebang problem on openSUSE
by Anonymous Monk on Mar 24, 2018 at 03:05 UTC

    ... perl -l parses the run time options by itself ...

    I meant perl the interpreter parses the options, not perl -l.