From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 9697C1F463; Thu, 26 Sep 2019 02:49:38 +0000 (UTC) Date: Thu, 26 Sep 2019 02:49:38 +0000 From: Eric Wong To: Alyssa Ross Cc: meta@public-inbox.org Subject: Re: [PATCH] #!/usr/bin/perl -> #!/usr/bin/env perl Message-ID: <20190926024938.GA19132@dcvr> References: <20190924204312.7875-1-hi@alyssa.is> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190924204312.7875-1-hi@alyssa.is> List-Id: Alyssa Ross wrote: > It's much more reasonable to assume that the Perl a user wants to use > is the one they have in their path, rather than whatever one has been > installed system-wide by their distribution (if any!). I used to think that, too... Nowadays, I would only use "/usr/bin/env perl" for standalone or standard-library-only scripts; but nothing with non-standard-library dependencies. Some general notes: * Perl will parse the "-w" in a shebang even if it's invoked as "perl /path/to/script" without the "-w" * "-w" is stronger than "use warnings", in that it applies to the whole program rather than the scope of "use warnings" * Different Perl installations can have different modules installed for it, so relying on /usr/bin/env can lead to surprises + failures when libraries are missing. * "/usr/bin/env perl" won't take into account "perl5.xx" names that dev versions of Perl get installed as by default, so shebang rewriting is necessary for anything end users would use, anyways. * I've been looking into startup time of some scripts, and "use warnings" adds more open() syscalls which affects performance a miniscule amount (maybe more for Intel CPUs with vulnerabilities). So I might get rid of some "use warnings" in those paths rely on "-w" down the line... Reordering the diffstat slightly... > Makefile.PL | 3 ++- Makefile.PL doesn't have the executable bit set, and all the documentation says to run it as "perl Makefile.PL" The reason for the shebang is for external tools, highlighters and stuff like file(1). > Documentation/extman.perl | 3 ++- > Documentation/standards.perl | 3 ++- Makefile.PL writes a Makefile which sets $(PERL), with an absolute path to run those files. > certs/create-certs.perl | 2 +- Documentation in corresponding t/*.t files could be better about running that and instead recommend "$^X" > ci/deps.perl | 3 ++- That's only run via $PERL (which defaults to 'perl') > examples/cgit.psgi | 2 +- > examples/highlight.psgi | 2 +- > examples/newswww.psgi | 2 +- > examples/public-inbox.psgi | 2 +- > examples/unsubscribe.psgi | 3 ++- > t/git-http-backend.psgi | 2 +- I only had the shebang there for external tools. Running a .psgi directly via Perl wouldn't work. "#!/usr/bin/plackup" might work if it was executable, but I'm not sure if people do that w/o command-line options. > examples/unsubscribe.milter | 2 +- That could probably be installed via Makefile using $(FIXIN) like the rest of the stuff in script/ below (but not by default). > script/public-inbox-compact | 2 +- > script/public-inbox-convert | 2 +- > script/public-inbox-edit | 2 +- > script/public-inbox-httpd | 2 +- > script/public-inbox-index | 2 +- > script/public-inbox-init | 2 +- > script/public-inbox-learn | 2 +- > script/public-inbox-mda | 2 +- > script/public-inbox-nntpd | 2 +- > script/public-inbox-purge | 2 +- > script/public-inbox-watch | 2 +- > script/public-inbox-xcpdb | 3 ++- > script/public-inbox.cgi | 2 +- All of these are handled by $(FIXIN) in the Makefile. I install these on FreeBSD which puts Perl in /usr/local/bin and never had a problem. > scripts/dupe-finder | 2 +- > scripts/import_maildir | 2 +- > scripts/import_slrnspool | 2 +- > scripts/import_vger_from_mbox | 2 +- > scripts/slrnspool2maildir | 2 +- > scripts/ssoma-replay | 3 ++- > scripts/xhdr-num2mid | 2 +- > t/check-www-inbox.perl | 2 +- None of these are really serious scripts, and if they're run; it's always via "perl /path/to/script" > t/hl_mod.t | 2 +- Oops, there probably shouldn't have a shebang there at all since none of the other *.t files have it. I've also seen "#!perl -w" (no '/' at all) in other projects, but I don't think it's worth the effort unless some external tools/highlighters work better with it. I expect "#!/usr/bin/perl -w" to be most compatible with highlighters and stuff like file(1).