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

Shebang line parsing mystery

Thread Next
Rafael Garcia-Suarez
January 16, 2012 05:14
Shebang line parsing mystery
Message ID:
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
print "version $]\n";

~§ perl
print "version $]\n";

~§ cat
#!/bin/cat indir
print "version $]\n";

~§ perl
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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About