make adds an 'exec' line to my scripts

ぃ、小莉子 提交于 2020-01-15 10:59: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



来源:https://stackoverflow.com/questions/6795713/make-adds-an-exec-line-to-my-scripts

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!