Bug#344269: lintian: false executable-not-elf-or-script warning with perl magic header
Frank Küster <frank@kuesterei.ch> writes:
> Err, it only runs without it, but I guess that's because the shebang
> line should be "#!/usr/bin/perl", not "#!/bin/sh".
Hm, the whole point of that sort of magic is that it's supposed to handle
being run under the shell. But indeed I can duplicate this, and I'm
completely mystified why. If one omits #!/bin/sh, it runs fine, even
though this still spawns a shell. If one includes it, Perl is spawned and
then appears to exec /bin/sh to run the script again but passes the -wS
option to it, at which point it fails due to an invlaid option.
I have no idea why that would be happening. Some bizarre code in perl -S
maybe? Maybe perl -S tries to honor the #! line?
> This tells me that the purpose of the magic is to be able to start the
> script with perl even on systems that do not understand the shebang
> line. I was thinking (and am still unsure) that there is an additional
> purpose: Being able to run the script without relying on a specific
> path for perl.
Yes, but there's a much easier way to do that if that's all you want.
#!/usr/bin/env perl
(Or perl -S for some weird platforms, although I've never seen that be
necesary.) It's quite common for Python scripts to use this technique.
> So the question is whether it's worth to patch upstream's script just to
> have a "nice" shebang line, while it works fine without it, but in any
> case this isn't a bug in lintian, but a question about overriding or
> fixing.
Well, give that this weird construct works and only works without the
shebang line, maybe fixing lintian to recognize it and not complain about
it *is* the right thing to do. Although the problem it's addressing seems
pretty obscure to me at this point.
--
Russ Allbery (rra@debian.org) <http://www.eyrie.org/~eagle/>
Reply to: