What is the exact meaning of the find2perl perl shebang + eval?

后端 未结 2 1142
走了就别回头了
走了就别回头了 2021-01-06 08:48

What exacly do the following?

#! /usr/bin/perl -w
    eval \'exec /usr/bin/perl -S $0 ${1+\"$@\"}\'
        if 0; #$running_under_some_shell
<
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-06 09:17

    I found some discussion here: http://www.perlmonks.org/?node_id=825147

    The extended hashbang is there so you can run your Perl script with almost any /bin/sh under the sun, even a shell/kernel that does not honor the hashbang and it will still launch perl in the end.

提交回复
热议问题