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

Shebang line parsing mystery

Thread Next
From:
Rafael Garcia-Suarez
Date:
January 16, 2012 05:14
Subject:
Shebang line parsing mystery
Message ID:
CAMoYMM-Y6YMThSJknxeyoAWujNkjaCN6fY8fWmNEQK5ALj+d4Q@mail.gmail.com
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, and it's not
documented. Any idea why this could have been included there by Larry
?

Personally I wouldn't object to the removal of this exec feature. But
at the very least shouldn't we document that "indir" thing ?

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