develooper Front page | perl.perl5.porters | Postings from January 2012

Re: Shebang line parsing mystery

Thread Previous | Thread Next
From:
Eric Brine
Date:
January 17, 2012 00:29
Subject:
Re: Shebang line parsing mystery
Message ID:
CALJW-qGf=LDcS0X5V8mcQqu9ZiGE83TmjmZ4pKZddiqZUgCwgQ@mail.gmail.com
On Mon, Jan 16, 2012 at 8:14 AM, Rafael Garcia-Suarez <rgs@consttype.org>wrote:

> I know that perlrun states this :
>
> If the C<#!> line does not contain the word "perl", the program named after
> the C<#!> is executed instead of the Perl interpreter.  This is slightly
> bizarre, but it helps people on machines that don't do C<#!>, because they
> can tell a program that their SHELL is F</usr/bin/perl>, and Perl will then
> dispatch the program to the correct interpreter for them.
>
> That feature can be questioned, esp. for Unix-like platforms, but it's
> not my point there; if I look at the code that execs the program
> specified on the #! line, I see that it also looks for the characters
> "indir" there. And indeed, that disables the exec :
>
> ~§ cat sb.pl
> #!/bin/cat
> print "version $]\n";
>
> ~§ perl sb.pl
> #!/bin/cat
> print "version $]\n";
>
> ~§ cat sb2.pl
> #!/bin/cat indir
> print "version $]\n";
>
> ~§ perl sb2.pl
> version 5.014001
>
> According to git-blame, this has been this way forever


After
perl 5.0 alpha 6
8990e3071044a96302560bbdb5706f3e74cf1bef

But no later than
perl 5.0 alpha 8
2304df62caa7d9be70e8b8bcdb454e139c9c103d


> and it's not documented.


And it wasn't back then either. (OMG! the Perl docs consisted of one file!)

- Eric

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About