Use env for all perl invocations
cover Use env for all perl invocations
I spent a little while debugging why git-format-patch refused to believe that SSL support was installed (Can't locate Net/SMTP/SSL.pm in @INC...) Turns out that it was installed for my system's preferred /usr/local/bin/perl, but not for git-format-patch's hard-coded /usr/bin/perl; changing the shebang allowed git format-patch to work as expected.
This patch set converts all perl invocations in git to use env so that the user-preferred perl interpreter is always used.
Pat Pannuto (2):
Convert all 'perl -w' to 'perl' + 'use warnings;' Use 'env' to find perl instead of fixed path
Documentation/build-docdep.perl | 2 +- Documentation/cat-texi.perl | 4 +++- Documentation/cmd-list.perl | 4 +++- Documentation/fix-texi.perl | 4 +++- Documentation/lint-gitlink.perl | 2 +- compat/vcbuild/scripts/clink.pl | 3 ++- compat/vcbuild/scripts/lib.pl | 3 ++- contrib/buildsystems/engine.pl | 3 ++- contrib/buildsystems/generate | 3 ++- contrib/buildsystems/parse.pl | 3 ++- contrib/contacts/git-contacts | 2 +- contrib/credential/netrc/git-credential-netrc | 2 +- contrib/credential/netrc/test.pl | 2 +- contrib/diff-highlight/diff-highlight | 2 +- contrib/examples/git-remote.perl | 3 ++- contrib/examples/git-rerere.perl | 2 +- contrib/examples/git-svnimport.perl | 2 +- contrib/fast-import/git-import.perl | 2 +- contrib/fast-import/import-directories.perl | 2 +- contrib/fast-import/import-tars.perl | 2 +- contrib/hooks/setgitperms.perl | 2 +- contrib/hooks/update-paranoid | 2 +- contrib/long-running-filter/example.pl | 2 +- contrib/mw-to-git/git-mw.perl | 2 +- contrib/mw-to-git/git-remote-mediawiki.perl | 2 +- contrib/mw-to-git/t/test-gitmw.pl | 5 ++++- contrib/stats/mailmap.pl | 2 +- contrib/stats/packinfo.pl | 2 +- git-add--interactive.perl | 2 +- git-archimport.perl | 2 +- git-cvsexportcommit.perl | 2 +- git-cvsimport.perl | 2 +- git-cvsserver.perl | 2 +- git-difftool.perl | 2 +- git-relink.perl | 2 +- git-send-email.perl | 2 +- git-svn.perl | 2 +- gitweb/gitweb.perl | 2 +- t/Git-SVN/Utils/can_compress.t | 2 +- t/Git-SVN/Utils/fatal.t | 2 +- t/check-non-portable-shell.pl | 2 +- t/gitweb-lib.sh | 2 +- t/perf/aggregate.perl | 2 +- t/perf/min_time.perl | 2 +- t/t0202/test.pl | 2 +- t/t4034/perl/post | 2 +- t/t4034/perl/pre | 2 +- t/t9000/test.pl | 2 +- t/t9500-gitweb-standalone-no-errors.sh | 2 +- t/t9700/test.pl | 2 +- t/test-terminal.perl | 2 +- 51 files changed, 66 insertions(+), 51 deletions(-)
Signature · 1 line
2.11.0
PATCH 1/2 Convert all 'perl -w' to 'perl' + 'use warnings;'
This commit is in preparation for converting all shebangs to use 'env' instead of a fixed perl path, which will not allow for arguments to 'perl'.
--- Documentation/cat-texi.perl | 4 +++- Documentation/cmd-list.perl | 4 +++- Documentation/fix-texi.perl | 4 +++- compat/vcbuild/scripts/clink.pl | 3 ++- compat/vcbuild/scripts/lib.pl | 3 ++- contrib/buildsystems/engine.pl | 3 ++- contrib/buildsystems/generate | 3 ++- contrib/buildsystems/parse.pl | 3 ++- contrib/examples/git-remote.perl | 3 ++- contrib/mw-to-git/t/test-gitmw.pl | 5 ++++- 10 files changed, 25 insertions(+), 10 deletions(-)
Documentation/cat-texi.perl +3 -1
@@ -1,4 +1,6 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl + +use warnings; my @menu = (); my $output = $ARGV[0];
Documentation/cmd-list.perl +3 -1
@@ -1,4 +1,6 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl + +use warnings; use File::Compare qw(compare);
Documentation/fix-texi.perl +3 -1
@@ -1,4 +1,6 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl + +use warnings; while (<>) { if (/^\@setfilename/) {
compat/vcbuild/scripts/clink.pl +2 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl ###################################################################### # Compiles or links files #
@@ -10,6 +10,7 @@ # Copyright (C) 2009 Marius Storm-Olsen <[email protected]> ###################################################################### use strict; +use warnings; my @args = (); my @cflags = (); my $is_linking = 0;
compat/vcbuild/scripts/lib.pl +2 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl ###################################################################### # Libifies files on Windows #
@@ -10,6 +10,7 @@ # Copyright (C) 2009 Marius Storm-Olsen <[email protected]> ###################################################################### use strict; +use warnings; my @args = (); while (@ARGV) { my $arg = shift @ARGV;
contrib/buildsystems/engine.pl +2 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl ###################################################################### # Do not call this script directly! #
@@ -8,6 +8,7 @@ # Copyright (C) 2009 Marius Storm-Olsen <[email protected]> ###################################################################### use strict; +use warnings; use File::Basename; use File::Spec; use Cwd;
contrib/buildsystems/generate +2 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl ###################################################################### # Generate buildsystem files #
@@ -19,6 +19,7 @@ # Copyright (C) 2009 Marius Storm-Olsen <[email protected]> ###################################################################### use strict; +use warnings; use File::Basename; use Cwd;
contrib/buildsystems/parse.pl +2 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl ###################################################################### # Do not call this script directly! #
@@ -8,6 +8,7 @@ # Copyright (C) 2009 Marius Storm-Olsen <[email protected]> ###################################################################### use strict; +use warnings; use File::Basename; use Cwd;
contrib/examples/git-remote.perl +2 -1
@@ -1,6 +1,7 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl use strict; +use warnings; use Git; my $git = Git->repository();
contrib/mw-to-git/t/test-gitmw.pl +4 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl -w -s +#!/usr/bin/perl # Copyright (C) 2012 # Charles Roussel <[email protected]> # Simon Cathebras <[email protected]>
@@ -22,6 +22,9 @@ # "edit_page" # "getallpagename" +use strict; +use warnings; + use MediaWiki::API; use Getopt::Long; use encoding 'utf8';
Signature · 1 line
2.11.0
PATCH 2/2 Use 'env' to find perl instead of fixed path
In reply to Pat PannutoDepending on system configuration, /usr/bin/perl may not be the preferred perl interpreter, use /usr/bin/env perl to invoke perl instead to repsect user preferences.
In most cases this will not matter as any perl install will work, but for applications such as git-format-patch, which may require plugins such as Net/SMTP/SSL.pm to be installed, it is very confusing when git fails to work after installation because it chose the wrong perl installation.
This patch converts all shebangs to use env for consistency across the project.
--- Documentation/build-docdep.perl | 2 +- Documentation/cat-texi.perl | 2 +- Documentation/cmd-list.perl | 2 +- Documentation/fix-texi.perl | 2 +- Documentation/lint-gitlink.perl | 2 +- compat/vcbuild/scripts/clink.pl | 2 +- compat/vcbuild/scripts/lib.pl | 2 +- contrib/buildsystems/engine.pl | 2 +- contrib/buildsystems/generate | 2 +- contrib/buildsystems/parse.pl | 2 +- contrib/contacts/git-contacts | 2 +- contrib/credential/netrc/git-credential-netrc | 2 +- contrib/credential/netrc/test.pl | 2 +- contrib/diff-highlight/diff-highlight | 2 +- contrib/examples/git-remote.perl | 2 +- contrib/examples/git-rerere.perl | 2 +- contrib/examples/git-svnimport.perl | 2 +- contrib/fast-import/git-import.perl | 2 +- contrib/fast-import/import-directories.perl | 2 +- contrib/fast-import/import-tars.perl | 2 +- contrib/hooks/setgitperms.perl | 2 +- contrib/hooks/update-paranoid | 2 +- contrib/long-running-filter/example.pl | 2 +- contrib/mw-to-git/git-mw.perl | 2 +- contrib/mw-to-git/git-remote-mediawiki.perl | 2 +- contrib/mw-to-git/t/test-gitmw.pl | 2 +- contrib/stats/mailmap.pl | 2 +- contrib/stats/packinfo.pl | 2 +- git-add--interactive.perl | 2 +- git-archimport.perl | 2 +- git-cvsexportcommit.perl | 2 +- git-cvsimport.perl | 2 +- git-cvsserver.perl | 2 +- git-difftool.perl | 2 +- git-relink.perl | 2 +- git-send-email.perl | 2 +- git-svn.perl | 2 +- gitweb/gitweb.perl | 2 +- t/Git-SVN/Utils/can_compress.t | 2 +- t/Git-SVN/Utils/fatal.t | 2 +- t/check-non-portable-shell.pl | 2 +- t/gitweb-lib.sh | 2 +- t/perf/aggregate.perl | 2 +- t/perf/min_time.perl | 2 +- t/t0202/test.pl | 2 +- t/t4034/perl/post | 2 +- t/t4034/perl/pre | 2 +- t/t9000/test.pl | 2 +- t/t9500-gitweb-standalone-no-errors.sh | 2 +- t/t9700/test.pl | 2 +- t/test-terminal.perl | 2 +- 51 files changed, 51 insertions(+), 51 deletions(-)
Documentation/build-docdep.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl my %include = (); my %included = ();
Documentation/cat-texi.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use warnings;
Documentation/cmd-list.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use warnings;
Documentation/fix-texi.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use warnings;
Documentation/lint-gitlink.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use File::Find; use Getopt::Long;
compat/vcbuild/scripts/clink.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl ###################################################################### # Compiles or links files #
compat/vcbuild/scripts/lib.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl ###################################################################### # Libifies files on Windows #
contrib/buildsystems/engine.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl ###################################################################### # Do not call this script directly! #
contrib/buildsystems/generate +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl ###################################################################### # Generate buildsystem files #
contrib/buildsystems/parse.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl ###################################################################### # Do not call this script directly! #
contrib/contacts/git-contacts +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # List people who might be interested in a patch. Useful as the argument to # git-send-email --cc-cmd option, and in other situations.
contrib/credential/netrc/git-credential-netrc +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; use warnings;
contrib/credential/netrc/test.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use warnings; use strict;
contrib/diff-highlight/diff-highlight +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use 5.008; use warnings FATAL => 'all';
contrib/examples/git-remote.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; use warnings;
contrib/examples/git-rerere.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # REuse REcorded REsolve. This tool records a conflicted automerge # result and its hand resolution, and helps to resolve future
contrib/examples/git-svnimport.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # This tool is copyright (c) 2005, Matthias Urlichs. # It is released under the Gnu Public License, version 2.
contrib/fast-import/git-import.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Performs an initial import of a directory. This is the equivalent # of doing 'git init; git add .; git commit'. It's a little slower,
contrib/fast-import/import-directories.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Copyright 2008-2009 Peter Krefting <[email protected]> #
contrib/fast-import/import-tars.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl ## tar archive frontend for git-fast-import ##
contrib/hooks/setgitperms.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Copyright (c) 2006 Josh England #
contrib/hooks/update-paranoid +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; use File::Spec;
contrib/long-running-filter/example.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Example implementation for the Git filter protocol version 2 # See Documentation/gitattributes.txt, section "Filter Protocol"
contrib/mw-to-git/git-mw.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Copyright (C) 2013 # Benoit Person <[email protected]>
contrib/mw-to-git/git-remote-mediawiki.perl +1 -1
@@ -1,4 +1,4 @@ -#! /usr/bin/perl +#!/usr/bin/env perl # Copyright (C) 2011 # Jérémie Nikaes <[email protected]>
contrib/mw-to-git/t/test-gitmw.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Copyright (C) 2012 # Charles Roussel <[email protected]> # Simon Cathebras <[email protected]>
contrib/stats/mailmap.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use warnings 'all'; use strict;
contrib/stats/packinfo.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # This tool will print vaguely pretty information about a pack. It # expects the output of "git verify-pack -v" as input on stdin.
git-add--interactive.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use 5.008; use strict;
git-archimport.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # This tool is copyright (c) 2005, Martin Langhoff. # It is released under the Gnu Public License, version 2.
git-cvsexportcommit.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use 5.008; use strict;
git-cvsimport.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # This tool is copyright (c) 2005, Matthias Urlichs. # It is released under the Gnu Public License, version 2.
git-cvsserver.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl #### #### This application is a CVS emulation layer for git.
git-difftool.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Copyright (c) 2009, 2010 David Aguilar # Copyright (c) 2012 Tim Henigan #
git-relink.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Copyright 2005, Ryan Anderson <[email protected]> # Distribution permitted under the GPL v2, as distributed # by the Free Software Foundation.
git-send-email.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # # Copyright 2002,2005 Greg Kroah-Hartman <[email protected]> # Copyright 2005 Ryan Anderson <[email protected]>
git-svn.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Copyright (C) 2006, Eric Wong <[email protected]> # License: GPL v2 or later use 5.008;
gitweb/gitweb.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # gitweb - simple web interface to track changes in git repositories #
t/Git-SVN/Utils/can_compress.t +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; use warnings;
t/Git-SVN/Utils/fatal.t +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict; use warnings;
t/check-non-portable-shell.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Test t0000..t9999.sh for non portable shell scripts # This script can be called with one or more filenames as parameters
t/gitweb-lib.sh +1 -1
@@ -7,7 +7,7 @@ gitweb_init () { safe_pwd="$(perl -MPOSIX=getcwd -e 'print quotemeta(getcwd)')" cat >gitweb_config.perl <<EOF -#!/usr/bin/perl +#!/usr/bin/env perl # gitweb configuration for tests
t/perf/aggregate.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use lib '../../perl/blib/lib'; use strict;
t/perf/min_time.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl my $minrt = 1e100; my $min;
t/t0202/test.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use 5.008; use lib (split(/:/, $ENV{GITPERLLIB})); use strict;
t/t4034/perl/post +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict;
t/t4034/perl/pre +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use strict;
t/t9000/test.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use lib (split(/:/, $ENV{GITPERLLIB})); use 5.008;
t/t9500-gitweb-standalone-no-errors.sh +1 -1
@@ -712,7 +712,7 @@ test_expect_success HIGHLIGHT \ test_expect_success HIGHLIGHT \ 'syntax highlighting (highlighter language autodetection)' \ 'git config gitweb.highlight yes && - echo "#!/usr/bin/perl" > test && + echo "#!/usr/bin/env perl" > test && git add test && git commit -m "Add test" && gitweb_run "p=.git;a=blob;f=test"'
t/t9700/test.pl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use lib (split(/:/, $ENV{GITPERLLIB})); use 5.008;
t/test-terminal.perl +1 -1
@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use 5.008; use strict; use warnings;
Signature · 1 line
2.11.0
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Am 12.01.2017 um 06:51 schrieb Pat Pannuto:
git-add--interactive.perl line 1
Quoted 7 lines
git-add--interactive.perl +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl
This change, and all others that affect installed external git programs, is a no-go. On Windows, our execve emulation is not complete. It would invoke only env (looked up in PATH), but not pass 'perl' as argument.
Sorry for the bad news.
I would have suggested to set PERL_PATH in your config.mak, but that does not change the generated perl scripts, I think. Perhaps you should implement that?
I'm not thrilled about your changes to the test scripts, but I do not expect that they break on Windows.
-- Hannes
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
I'm not at all attached to changing all of them, just figured it made sense while I was here.
Would a patch that changes only:
git-add--interactive.perl | 2 +- git-archimport.perl | 2 +- git-cvsexportcommit.perl | 2 +- git-cvsimport.perl | 2 +- git-cvsserver.perl | 2 +- git-difftool.perl | 2 +- git-relink.perl | 2 +- git-send-email.perl | 2 +- git-svn.perl | 2 +-
be more acceptable?
Quoted 26 lines · Johannes Sixt
Am 12.01.2017 um 06:51 schrieb Pat Pannuto:
git-add--interactive.perl line 1
Quoted 8 lines
git-add--interactive.perl +1
-1@@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perlThis change, and all others that affect installed external git programs, is a no-go. On Windows, our execve emulation is not complete. It would invoke only
env(looked up in PATH), but not pass 'perl' as argument.Sorry for the bad news.
I would have suggested to set
PERL_PATHin your config.mak, but that does not change the generated perl scripts, I think. Perhaps you should implement that?I'm not thrilled about your changes to the test scripts, but I do not expect that they break on Windows.
-- Hannes
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Hi Pat,
Quoted 15 lines · Pat Pannuto
I'm not at all attached to changing all of them, just figured it made sense while I was here.
Would a patch that changes only:
git-add--interactive.perl | 2 +- git-archimport.perl | 2 +- git-cvsexportcommit.perl | 2 +- git-cvsimport.perl | 2 +- git-cvsserver.perl | 2 +- git-difftool.perl | 2 +- git-relink.perl | 2 +- git-send-email.perl | 2 +- git-svn.perl | 2 +-
Quoted 1 line
be more acceptable?
Unfortunately not. Take git-svn.perl for example, in particular in conjunction with Git for Windows. git-svn requires the Subversion bindings for Perl, and they are a *major* pain to build correctly (this is frequently underestimated by users who complain about git-svn problems).
Allowing users to override the Perl path (even if it were possible, which it is not, as Hannes Sixt pointed out in the mail you replied to) would open Git for Windows for a metric ton of users complaining that their git-svn does not work (when it is their fault, really, by overriding Perl with their own preferred version that comes without Subversion bindings, but how would they know).
So if this patch would make it into upstream Git, I would *have* to revert it in Git for Windows, adding to my already considerable maintenance burden.
Ciao,
Johannes
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Quoted 2 lines · Johannes Schindelin
So if this patch would make it into upstream Git, I would *have* to revert it in Git for Windows, adding to my already considerable maintenance burden.
I do not think we want "#!/usr/bin/env $language" in the upstream, either.
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
I'm happy to let this drop.
I've filed the missing perl library as a homebrew issue [1], so hopefully this won't be an issue for folks in the future.
You may still want the 1/2 patch in this series, just to make things internally consistent with "-w" vs "use warnings;" inside git's perl scripts.
-Pat
[1] https://github.com/Homebrew/homebrew-core/issues/8783
Quoted 8 lines · Junio C Hamano
Quoted 2 lines · Johannes Schindelin
So if this patch would make it into upstream Git, I would *have* to revert it in Git for Windows, adding to my already considerable maintenance burden.
I do not think we want "#!/usr/bin/env $language" in the upstream, either.
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Quoted 3 lines · Pat Pannuto
You may still want the 1/2 patch in this series, just to make things internally consistent with "-w" vs "use warnings;" inside git's perl scripts.
I do not think so. 1/2 is justified as a prerequisite of 2/2 and needs a different log message, so cannot be used as is.
I vaguely recall hearing arguments for and against the choice between "#!path-to-perl -w" vs "use warnings;" but do not recall the details to have a strong opinion either way, so we might even end up wanting to be "internally consistent" by going the other way. Please prepare a standalone patch with an update message to convince people why "use warnings;" is more preferable than "#!path-to-perl -w" and explaining that we are making things consistently use the more preferable form, if you want to go in that direction.
Thanks.
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
In reply to Pat PannutoQuoted 3 lines · Pat Pannuto
You may still want the 1/2 patch in this series, just to make things internally consistent with "-w" vs "use warnings;" inside git's perl scripts.
No, that is a step back. "-w" affects the entire process, so it spots more potential problems. The "warnings" pragma is scoped to the enclosing block, so it won't span across files.
Existing instances of "use warnings" should remain, but I would rather support adding "-w" to scripts which do not have it (and fixing newly-found warnings along the way).
Thanks.
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Hi Eric,
Quoted 7 lines · Eric Wong
Quoted 3 lines · Pat Pannuto
You may still want the 1/2 patch in this series, just to make things internally consistent with "-w" vs "use warnings;" inside git's perl scripts.
No, that is a step back. "-w" affects the entire process, so it spots more potential problems.
I guess I do not understand, still, what the difference is between using -w and adding use warnings *very early* in the script... Could you give an example where it makes a difference?
Ciao,
Dscho
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Quoted 3 lines · Johannes Schindelin
I guess I do not understand, still, what the difference is between using -w and adding
use warnings*very early* in the script... Could you give an example where it makes a difference?
"use warnings" won't leak across files/modules. In the following example, only the "useless use of join or string in void context" from void.perl gets shown w/o -w. The VoidExample.pm warning can get lost.
----- VoidExample.pm ------
package VoidExample;
use strict;
# use warnings; # uncomment to trigger warning on next line:
join('', qw(a b c));1;
------ void.perl ------
#!/usr/bin/perl
use strict;
use warnings;
use VoidExample;
join('', qw(a b c)); # warns
----------8<----------
$ perl -I . void.perl # 1 warning $ perl -w -I . void.perl # 2 warnings
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Hi Eric,
Quoted 9 lines · Eric Wong
Quoted 3 lines · Johannes Schindelin
I guess I do not understand, still, what the difference is between using -w and adding
use warnings*very early* in the script... Could you give an example where it makes a difference?"use warnings" won't leak across files/modules. In the following example, only the "useless use of join or string in void context" from void.perl gets shown w/o -w. The VoidExample.pm warning can get lost.
Okay, thanks!
Dscho
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
In reply to Eric WongQuoted 8 lines · Eric Wong
Quoted 3 lines · Pat Pannuto
You may still want the 1/2 patch in this series, just to make things internally consistent with "-w" vs "use warnings;" inside git's perl scripts.
No, that is a step back. "-w" affects the entire process, so it spots more potential problems. The "warnings" pragma is scoped to the enclosing block, so it won't span across files.
OK, so with "-w", we do not have to write "use warnings" in each of our files to get them checked. It is handy when we ship our own libs (e.g. Git.pm) that are used by our programs.
If something we write outselves trigger a false-positive, we can work it around with "no warnings;" in the smallest block that encloses the offending code in the worst case, or just rephrase it in a way that won't trigger a false-positive.
If something we _use_ from a third-party is not warnings-clean, there is no easy way to squelch them if we use "-w", which is a potential downside, isn't it? I do not know how serious a problem it is in practice. I suspect that the core package we use from perl distribution are supposed to be warnings-clean, but we use a handful of things from outside the core and I do not know what state they are in.
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Quoted 6 lines · Junio C Hamano
Quoted 5 lines · Eric Wong
Quoted 3 lines · Pat Pannuto
You may still want the 1/2 patch in this series, just to make things internally consistent with "-w" vs "use warnings;" inside git's perl scripts.
Quoted 7 lines
Quoted 3 lines
No, that is a step back. "-w" affects the entire process, so it spots more potential problems. The "warnings" pragma is scoped to the enclosing block, so it won't span across files.
OK, so with "-w", we do not have to write "use warnings" in each of our files to get them checked. It is handy when we ship our own libs (e.g. Git.pm) that are used by our programs.
Yes. "use warnings" should be in our own libs in case other people run without "-w"
Quoted 4 lines
If something we write outselves trigger a false-positive, we can work it around with "no warnings;" in the smallest block that encloses the offending code in the worst case, or just rephrase it in a way that won't trigger a false-positive.
Correct.
Quoted 7 lines
If something we _use_ from a third-party is not warnings-clean, there is no easy way to squelch them if we use "-w", which is a potential downside, isn't it? I do not know how serious a problem it is in practice. I suspect that the core package we use from perl distribution are supposed to be warnings-clean, but we use a handful of things from outside the core and I do not know what state they are in.
Yes, "-w" will trigger warnings in third party packages. Existing uses we have should be fine, and I think most Perl modules we use or would use are vigilant about being warnings-clean. If we have to leave off a "-w", there should probably be a comment at the top stating the reason:
#!/usr/bin/perl
# Not using "perl -w" since Foo::Bar <= X.Y.Y is not warnings-clean use strict;
use warnings;
use Foo::Bar;
...
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Quoted 11 lines · Eric Wong
Quoted 10 lines · Junio C Hamano
Quoted 8 lines · Eric Wong
Quoted 3 lines · Pat Pannuto
You may still want the 1/2 patch in this series, just to make things internally consistent with "-w" vs "use warnings;" inside git's perl scripts.
No, that is a step back. "-w" affects the entire process, so it spots more potential problems. The "warnings" pragma is scoped to the enclosing block, so it won't span across files.
Quoted 6 lines
Quoted 3 lines
OK, so with "-w", we do not have to write "use warnings" in each of our files to get them checked. It is handy when we ship our own libs (e.g. Git.pm) that are used by our programs.
Yes. "use warnings" should be in our own libs in case other people run without "-w"
Would it mean that we need both anyway? That is, add missing "use warnings" without removing "-w" from she-bang line?
Quoted 6 lines
Yes, "-w" will trigger warnings in third party packages. Existing uses we have should be fine, and I think most Perl modules we use or would use are vigilant about being warnings-clean. If we have to leave off a "-w", there should probably be a comment at the top stating the reason:
Quoted 6 lines
#!/usr/bin/perl
# Not using "perl -w" sinceFoo::Bar<= X.Y.Y is not warnings-clean use strict;
use warnings;
useFoo::Bar;
...
Good.
Speaking of Perl, I recall that somebody complained that we ship with and do use a stale copy of Error.pm that has been deprecated. I am not asking you to do so, but we may want to see somebody look into it (i.e. assessing the current situation, and if it indeed is desirable for us to wean ourselves away from Error.pm, update our codepaths that use it).
Thanks.
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Quoted 16 lines · Junio C Hamano
Quoted 15 lines · Eric Wong
Quoted 13 lines · Junio C Hamano
Quoted 8 lines · Eric Wong
Quoted 3 lines · Pat Pannuto
You may still want the 1/2 patch in this series, just to make things internally consistent with "-w" vs "use warnings;" inside git's perl scripts.
No, that is a step back. "-w" affects the entire process, so it spots more potential problems. The "warnings" pragma is scoped to the enclosing block, so it won't span across files.
OK, so with "-w", we do not have to write "use warnings" in each of our files to get them checked. It is handy when we ship our own libs (e.g. Git.pm) that are used by our programs.
Quoted 5 lines
Quoted 2 lines
Yes. "use warnings" should be in our own libs in case other people run without "-w"
Would it mean that we need both anyway? That is, add missing "use warnings" without removing "-w" from she-bang line?
Yes, we keep "use warnings" other people may use, at least. No harm in keeping that in top-level scripts, I guess.
Quoted 6 lines
Speaking of Perl, I recall that somebody complained that we ship with and do use a stale copy of Error.pm that has been deprecated. I am not asking you to do so, but we may want to see somebody look into it (i.e. assessing the current situation, and if it indeed is desirable for us to wean ourselves away from Error.pm, update our codepaths that use it).
Agreed, I'd definitely prefer to move towards the basic eval/die construct without relying on a bundled 3rd-party mechanism. But we might need a migration path for out-of-tree users of Git.pm (if any)...
I'm sure I've agreed this was a path we should be taking in the past, but did something about it myself. So yeah, maybe Pat or somebody else interested can take care of this :)
Thanks.
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
In reply to Eric WongQuoted 14 lines · Eric Wong
Quoted 7 lines
If something we _use_ from a third-party is not warnings-clean, there is no easy way to squelch them if we use "-w", which is a potential downside, isn't it? I do not know how serious a problem it is in practice. I suspect that the core package we use from perl distribution are supposed to be warnings-clean, but we use a handful of things from outside the core and I do not know what state they are in.
Yes, "-w" will trigger warnings in third party packages. Existing uses we have should be fine, and I think most Perl modules we use or would use are vigilant about being warnings-clean. If we have to leave off a "-w", there should probably be a comment at the top stating the reason:
Quoted 6 lines
#!/usr/bin/perl
# Not using "perl -w" sinceFoo::Bar<= X.Y.Y is not warnings-clean use strict;
use warnings;
useFoo::Bar;
...
Just as a devil's advocate, why do we care about warnings in third-party modules? Or more specifically, why do _users_ who are running Git care about them? We cannot fix them in Git. A user may report the error to the module author, but the module author may not be responsive, or even may not be inclined to fix the problem (because they have a particular opinion on that warning).
In the meantime, the user is stuck with an annoying warning message until Git is updated as you showed above. Why not just start there preemptively, and let module authors worry about their own warnings?
-Peff
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
Quoted 6 lines · Jeff King
Just as a devil's advocate, why do we care about warnings in third-party modules? Or more specifically, why do _users_ who are running Git care about them? We cannot fix them in Git. A user may report the error to the module author, but the module author may not be responsive, or even may not be inclined to fix the problem (because they have a particular opinion on that warning).
Every user is a potential developer(*). And I do feel we (git developers) should be at least somewhat responsible for helping maintain and fix the projects we depend on; or moving to alternatives if we can't fix them.
There is a chance a newly-introduced warning in a 3rd-party module points to a real problem with the way git uses it, too. Having that warning would help us fix or workaround the bug (either in git or the module).
I doubt any module author would be unresponsive to having a localized "no warnings" for special cases. AFAIK, "-w" is widespread amongst Perl users (unlike Ruby in my experience).
(*) I feel that more strongly in the git case, and even more so
for the Perl bits since the source is already on the user's machine.
Quoted 3 lines
In the meantime, the user is stuck with an annoying warning message until Git is updated as you showed above. Why not just start there preemptively, and let module authors worry about their own warnings?
I'm not saying we blindly start using '-w' everywhere today. But we may at least try it and see if it introduces new warnings, first, and only enable '-w' when it it looks quiet (and perhaps start working with module authors to fix warnings
if not).
As a user, I'd rather have some indication of where something might be wrong, than no warning at all when something does go wrong.
This message was removed from the archive.
Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
In reply to Pat PannutoHi Pat,
Quoted 3 lines · Pat Pannuto
You may still want the 1/2 patch in this series, just to make things internally consistent with "-w" vs "use warnings;" inside git's perl scripts.
Yes, I like that patch.
Ciao,
Johannes
Quoted 5 lines · Pat Pannuto
I spent a little while debugging why git-format-patch refused to believe that SSL support was installed (Can't locate Net/SMTP/SSL.pm in @INC...) Turns out that it was installed for my system's preferred
/usr/local/bin/perl, but not for git-format-patch's hard-coded/usr/bin/perl; changing the shebang allowed git format-patch to work as expected.
Isn't that an indication that you are not building correctly? Perhaps
$ git grep 'Define PERL_' Makefile
$ make PERL_PATH=/usr/local/bin/perlwould help?
[plain text re-send, sorry]
Interesting, I'm guessing this came from when git was installed (
https://github.com/Homebrew/homebrew-core/blob/master/Formula/git.rb#L50
), when the perl path was likely still /usr/bin/perl
It feels weird to me that the perl path is fixed at compile/install-time as opposed to run-time discovery -- this means users can't change their perl install without breaking git?
Quoted 15 lines · Junio C Hamano
Quoted 5 lines · Pat Pannuto
I spent a little while debugging why git-format-patch refused to believe that SSL support was installed (Can't locate Net/SMTP/SSL.pm in @INC...) Turns out that it was installed for my system's preferred
/usr/local/bin/perl, but not for git-format-patch's hard-coded/usr/bin/perl; changing the shebang allowed git format-patch to work as expected.Isn't that an indication that you are not building correctly? Perhaps
$ git grep 'Define PERL_' Makefile $ make PERL_PATH=/usr/local/bin/perlwould help?
Quoted 3 lines · Pat Pannuto
It feels weird to me that the perl path is fixed at compile/install-time as opposed to run-time discovery -- this means users can't change their perl install without breaking git?
Among the software packages that use interpreters like perl, python, ruby, etc., there are ones that seem to consider that it is a good idea to let "#!/usr/bin/env $language" pick whatever variant [*1*] of the $language that happens to be on end-user's $PATH.
Git does not subscribe to that thought, and it is done for very good reasons.
When you take a popular $language used by many software packages, it is more than likely that one particular end user uses more than one such package written in the same $language. If one assumes that there is one variant of $language such software packages can all use, then $PATH can be tweaked so that the common variant and no other variants of $language can be found and you are done.
However, that is too simplistic in real life. If you are using Git (which wants Perl 5.8 or later with certain libs) and some other software package that needs a much older Perl, there is no such single variant that can be placed on end-user's $PATH. Only when all the other software packages write their she-bang line without "env" and instead point at the exact variant they need, Git can use the "env" to rely on $PATH, but at that point, Git is being overly arrogant. It insists to be special among packages that use the same $language and wants the variant it needs to be on $PATH.
Git knows that the real-world is not simplistic. Git is not arrogant, either. And that is why it does not use "#!/usr/bin/env".
[Footnote]
*1* Here a "variant" of a $language refers to a binary of one
particular version of the $language, together with libs and extensions it uses that are installed on the system. You apparently have two variants, one installed as /usr/bin/perl, the other as /usr/local/bin/perl.