make adds an 'exec' line to my scripts

2019-08-02 21:22发布

问题:

I'm trying to build a perl package (module + scripts).

My Makefile.PL has the following to include my script

EXE_FILES => [
               'bin/somescript1',
             ],

But after installing the script, it adds the following to the beginning of the installed script.

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

Why does it do this and can I make it not include that?

回答1:

When ExtUtils::Makemaker installs your scripts, it modifies to the shebang line to use the path to the perl you used to build the distribution. That way, when you call the script, it uses the same perl that you used to install the dependencies.

Additionally, it adds that exec line. If, for some reason, the system starts your program in the shell instead of perl, the exec switches it to perl.

Leave it alone. This only helps you.

However, if you want to override it, you have to override the parts of Makemaker that install programs. If you want to cut off your arm, you'll have to find out how to do that yourself. It's all in the Makemaker docs.



回答2:

You should not worry about those lines. It's a way to make your script runnable with both Perl and the shell, making it super-portable.



回答3:

If you set the shebang line to #!/usr/bin/env perl you can exploit a bug in ExtUtils::MM_Unix and the eval line isn't added on install. This wil break if the installing host does not have a working /usr/bin/env



标签: perl cpan