[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#344269: lintian: false executable-not-elf-or-script warning with perl magic header



Russ Allbery <rra@debian.org> wrote:

> Frank Küster <frank@kuesterei.ch> writes:
>> Russ Allbery <rra@debian.org> wrote:
>>> Frank Küster <frank@debian.org> writes:
>
>>>> eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' && eval 'exec perl -S $0 $argv:q'
>>>>   if 0;
>>>> use strict;
>
>>> Is that the first line of the file?  Generally one still starts such a
>>> script with #!/bin/sh.  Otherwise, you're relying on the assumption
>>> that any unrecognized file is started under /bin/sh.
>
>> Yes, obviously upstream is relying on that, but it seems this is also
>> needed.  If I add a #!/bin/sh line, I get a shell error instead of perl
>> execution.  I don't know whether this means that the magic is not magic
>> enough, or what.
>
> Does the script run without #!/bin/sh then?  It would really surprise me
> if the script ran without it but didn't run with it, 

Err, it only runs without it, but I guess that's because the shebang
line should be "#!/usr/bin/perl", not "#!/bin/sh".

> man perlrun under the -S option explains what's going on here, 

Good to read an explanation of these magic lines, thank you.  

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, in fact if I move perl to /usr/local/bin, the script (without any
shebang line) still works, a normal perl script with #!/usr/bin/perl of
course not.

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. 

> but
> frankly, portability to systems that don't support #! lines or that start
> shell scripts in csh even if #!/bin/sh is on the first line of the file is
> just an intellectual exercise at this point.  

According to man perlrun, the first line must be #!/usr/bin/perl, and I
think I have just confused you with my misconception.  If it is in fact
supposed to work with #!/bin/sh, then I'm puzzled (because it doesn't),
and then I think this bug still applies (because I don't think it's a
worthwile goal to break things [on other systems] that work, just to
make it look nicer).

Regards, Frank

-- 
Frank Küster
Inst. f. Biochemie der Univ. Zürich
Debian Developer




Reply to: