git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/2] Use env for all perl invocations
@ 2017-01-12  5:51 Pat Pannuto
  2017-01-12  5:51 ` [PATCH 1/2] Convert all 'perl -w' to 'perl' + 'use warnings;' Pat Pannuto
                   ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Pat Pannuto @ 2017-01-12  5:51 UTC (permalink / raw)
  To: gitster, git; +Cc: 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.

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(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 24+ messages in thread

* [PATCH 1/2] Convert all 'perl -w' to 'perl' + 'use warnings;'
  2017-01-12  5:51 [PATCH 0/2] Use env for all perl invocations Pat Pannuto
@ 2017-01-12  5:51 ` Pat Pannuto
  2017-01-12  5:51 ` [PATCH 2/2] Use 'env' to find perl instead of fixed path Pat Pannuto
  2017-01-12  6:21 ` [PATCH 0/2] Use env for all perl invocations Junio C Hamano
  2 siblings, 0 replies; 24+ messages in thread
From: Pat Pannuto @ 2017-01-12  5:51 UTC (permalink / raw)
  To: gitster, git; +Cc: Pat Pannuto

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'.

Signed-off-by: Pat Pannuto <pat.pannuto@gmail.com>
---
 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(-)

diff --git a/Documentation/cat-texi.perl b/Documentation/cat-texi.perl
index 87437f8a9..1cd28b1b5 100755
--- a/Documentation/cat-texi.perl
+++ b/Documentation/cat-texi.perl
@@ -1,4 +1,6 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
+
+use warnings;
 
 my @menu = ();
 my $output = $ARGV[0];
diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
index 5aa73cfe4..ba640a441 100755
--- a/Documentation/cmd-list.perl
+++ b/Documentation/cmd-list.perl
@@ -1,4 +1,6 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
+
+use warnings;
 
 use File::Compare qw(compare);
 
diff --git a/Documentation/fix-texi.perl b/Documentation/fix-texi.perl
index ff7d78f62..c247aece7 100755
--- a/Documentation/fix-texi.perl
+++ b/Documentation/fix-texi.perl
@@ -1,4 +1,6 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
+
+use warnings;
 
 while (<>) {
 	if (/^\@setfilename/) {
diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl
index a87d0da51..46eb61c5c 100755
--- a/compat/vcbuild/scripts/clink.pl
+++ b/compat/vcbuild/scripts/clink.pl
@@ -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 <mstormo@gmail.com>
 ######################################################################
 use strict;
+use warnings;
 my @args = ();
 my @cflags = ();
 my $is_linking = 0;
diff --git a/compat/vcbuild/scripts/lib.pl b/compat/vcbuild/scripts/lib.pl
index d8054e469..e571b8470 100755
--- a/compat/vcbuild/scripts/lib.pl
+++ b/compat/vcbuild/scripts/lib.pl
@@ -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 <mstormo@gmail.com>
 ######################################################################
 use strict;
+use warnings;
 my @args = ();
 while (@ARGV) {
 	my $arg = shift @ARGV;
diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl
index 23da787dc..a173669ce 100755
--- a/contrib/buildsystems/engine.pl
+++ b/contrib/buildsystems/engine.pl
@@ -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 <mstormo@gmail.com>
 ######################################################################
 use strict;
+use warnings;
 use File::Basename;
 use File::Spec;
 use Cwd;
diff --git a/contrib/buildsystems/generate b/contrib/buildsystems/generate
index bc10f25ff..9af89454a 100755
--- a/contrib/buildsystems/generate
+++ b/contrib/buildsystems/generate
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 ######################################################################
 # Generate buildsystem files
 #
@@ -19,6 +19,7 @@
 # Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com>
 ######################################################################
 use strict;
+use warnings;
 use File::Basename;
 use Cwd;
 
diff --git a/contrib/buildsystems/parse.pl b/contrib/buildsystems/parse.pl
index c9656ece9..33ca89eb0 100755
--- a/contrib/buildsystems/parse.pl
+++ b/contrib/buildsystems/parse.pl
@@ -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 <mstormo@gmail.com>
 ######################################################################
 use strict;
+use warnings;
 use File::Basename;
 use Cwd;
 
diff --git a/contrib/examples/git-remote.perl b/contrib/examples/git-remote.perl
index d42df7b41..5bf3ffd4c 100755
--- a/contrib/examples/git-remote.perl
+++ b/contrib/examples/git-remote.perl
@@ -1,6 +1,7 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use strict;
+use warnings;
 use Git;
 my $git = Git->repository();
 
diff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl
index 0ff76259f..8d0e7c078 100755
--- a/contrib/mw-to-git/t/test-gitmw.pl
+++ b/contrib/mw-to-git/t/test-gitmw.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w -s
+#!/usr/bin/perl
 # Copyright (C) 2012
 #     Charles Roussel <charles.roussel@ensimag.imag.fr>
 #     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
@@ -22,6 +22,9 @@
 #     "edit_page"
 #     "getallpagename"
 
+use strict;
+use warnings;
+
 use MediaWiki::API;
 use Getopt::Long;
 use encoding 'utf8';
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-12  5:51 [PATCH 0/2] Use env for all perl invocations Pat Pannuto
  2017-01-12  5:51 ` [PATCH 1/2] Convert all 'perl -w' to 'perl' + 'use warnings;' Pat Pannuto
@ 2017-01-12  5:51 ` Pat Pannuto
  2017-01-12  6:27   ` Johannes Sixt
  2017-01-12  6:21 ` [PATCH 0/2] Use env for all perl invocations Junio C Hamano
  2 siblings, 1 reply; 24+ messages in thread
From: Pat Pannuto @ 2017-01-12  5:51 UTC (permalink / raw)
  To: gitster, git; +Cc: Pat Pannuto

Depending 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.

Signed-off-by: Pat Pannuto <pat.pannuto@gmail.com>
---
 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(-)

diff --git a/Documentation/build-docdep.perl b/Documentation/build-docdep.perl
index ba4205e03..dc50f21f3 100755
--- a/Documentation/build-docdep.perl
+++ b/Documentation/build-docdep.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 my %include = ();
 my %included = ();
diff --git a/Documentation/cat-texi.perl b/Documentation/cat-texi.perl
index 1cd28b1b5..98dcc2c42 100755
--- a/Documentation/cat-texi.perl
+++ b/Documentation/cat-texi.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use warnings;
 
diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
index ba640a441..f440eebe3 100755
--- a/Documentation/cmd-list.perl
+++ b/Documentation/cmd-list.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use warnings;
 
diff --git a/Documentation/fix-texi.perl b/Documentation/fix-texi.perl
index c247aece7..61287a0a9 100755
--- a/Documentation/fix-texi.perl
+++ b/Documentation/fix-texi.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use warnings;
 
diff --git a/Documentation/lint-gitlink.perl b/Documentation/lint-gitlink.perl
index 476cc30b8..3e4b00eda 100755
--- a/Documentation/lint-gitlink.perl
+++ b/Documentation/lint-gitlink.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use File::Find;
 use Getopt::Long;
diff --git a/compat/vcbuild/scripts/clink.pl b/compat/vcbuild/scripts/clink.pl
index 46eb61c5c..857847703 100755
--- a/compat/vcbuild/scripts/clink.pl
+++ b/compat/vcbuild/scripts/clink.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 ######################################################################
 # Compiles or links files
 #
diff --git a/compat/vcbuild/scripts/lib.pl b/compat/vcbuild/scripts/lib.pl
index e571b8470..9b43f1270 100755
--- a/compat/vcbuild/scripts/lib.pl
+++ b/compat/vcbuild/scripts/lib.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 ######################################################################
 # Libifies files on Windows
 #
diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl
index a173669ce..ace1fd4bf 100755
--- a/contrib/buildsystems/engine.pl
+++ b/contrib/buildsystems/engine.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 ######################################################################
 # Do not call this script directly!
 #
diff --git a/contrib/buildsystems/generate b/contrib/buildsystems/generate
index 9af89454a..d6ce919cb 100755
--- a/contrib/buildsystems/generate
+++ b/contrib/buildsystems/generate
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 ######################################################################
 # Generate buildsystem files
 #
diff --git a/contrib/buildsystems/parse.pl b/contrib/buildsystems/parse.pl
index 33ca89eb0..492acf447 100755
--- a/contrib/buildsystems/parse.pl
+++ b/contrib/buildsystems/parse.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 ######################################################################
 # Do not call this script directly!
 #
diff --git a/contrib/contacts/git-contacts b/contrib/contacts/git-contacts
index dbe2abf27..70ec2039a 100755
--- a/contrib/contacts/git-contacts
+++ b/contrib/contacts/git-contacts
@@ -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.
diff --git a/contrib/credential/netrc/git-credential-netrc b/contrib/credential/netrc/git-credential-netrc
index 1571a7b26..ec8178f26 100755
--- a/contrib/credential/netrc/git-credential-netrc
+++ b/contrib/credential/netrc/git-credential-netrc
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
diff --git a/contrib/credential/netrc/test.pl b/contrib/credential/netrc/test.pl
index 169b6463c..6b44ba54d 100755
--- a/contrib/credential/netrc/test.pl
+++ b/contrib/credential/netrc/test.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use warnings;
 use strict;
diff --git a/contrib/diff-highlight/diff-highlight b/contrib/diff-highlight/diff-highlight
index 81bd8040e..ecf419542 100755
--- a/contrib/diff-highlight/diff-highlight
+++ b/contrib/diff-highlight/diff-highlight
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use 5.008;
 use warnings FATAL => 'all';
diff --git a/contrib/examples/git-remote.perl b/contrib/examples/git-remote.perl
index 5bf3ffd4c..2c8f18a13 100755
--- a/contrib/examples/git-remote.perl
+++ b/contrib/examples/git-remote.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
diff --git a/contrib/examples/git-rerere.perl b/contrib/examples/git-rerere.perl
index 4f692091e..110c27f4f 100755
--- a/contrib/examples/git-rerere.perl
+++ b/contrib/examples/git-rerere.perl
@@ -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
diff --git a/contrib/examples/git-svnimport.perl b/contrib/examples/git-svnimport.perl
index c414f0d9c..d183a8d66 100755
--- a/contrib/examples/git-svnimport.perl
+++ b/contrib/examples/git-svnimport.perl
@@ -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.
diff --git a/contrib/fast-import/git-import.perl b/contrib/fast-import/git-import.perl
index 0891b9e36..440790523 100755
--- a/contrib/fast-import/git-import.perl
+++ b/contrib/fast-import/git-import.perl
@@ -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,
diff --git a/contrib/fast-import/import-directories.perl b/contrib/fast-import/import-directories.perl
index 4dec1f18e..197307570 100755
--- a/contrib/fast-import/import-directories.perl
+++ b/contrib/fast-import/import-directories.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright 2008-2009 Peter Krefting <peter@softwolves.pp.se>
 #
diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl
index d60b4315e..30f3ff384 100755
--- a/contrib/fast-import/import-tars.perl
+++ b/contrib/fast-import/import-tars.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 ## tar archive frontend for git-fast-import
 ##
diff --git a/contrib/hooks/setgitperms.perl b/contrib/hooks/setgitperms.perl
index 2770a1b1d..18444e015 100755
--- a/contrib/hooks/setgitperms.perl
+++ b/contrib/hooks/setgitperms.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright (c) 2006 Josh England
 #
diff --git a/contrib/hooks/update-paranoid b/contrib/hooks/update-paranoid
index d18b317b2..95595acf5 100755
--- a/contrib/hooks/update-paranoid
+++ b/contrib/hooks/update-paranoid
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use File::Spec;
diff --git a/contrib/long-running-filter/example.pl b/contrib/long-running-filter/example.pl
index a677569dd..0ca49e370 100755
--- a/contrib/long-running-filter/example.pl
+++ b/contrib/long-running-filter/example.pl
@@ -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"
diff --git a/contrib/mw-to-git/git-mw.perl b/contrib/mw-to-git/git-mw.perl
index 28df3ee32..50c0549b5 100755
--- a/contrib/mw-to-git/git-mw.perl
+++ b/contrib/mw-to-git/git-mw.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 # Copyright (C) 2013
 #     Benoit Person <benoit.person@ensimag.imag.fr>
diff --git a/contrib/mw-to-git/git-remote-mediawiki.perl b/contrib/mw-to-git/git-remote-mediawiki.perl
index 41e74fba1..f8ce245cf 100755
--- a/contrib/mw-to-git/git-remote-mediawiki.perl
+++ b/contrib/mw-to-git/git-remote-mediawiki.perl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl
+#!/usr/bin/env perl
 
 # Copyright (C) 2011
 #     Jérémie Nikaes <jeremie.nikaes@ensimag.imag.fr>
diff --git a/contrib/mw-to-git/t/test-gitmw.pl b/contrib/mw-to-git/t/test-gitmw.pl
index 8d0e7c078..a8272d942 100755
--- a/contrib/mw-to-git/t/test-gitmw.pl
+++ b/contrib/mw-to-git/t/test-gitmw.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2012
 #     Charles Roussel <charles.roussel@ensimag.imag.fr>
 #     Simon Cathebras <simon.cathebras@ensimag.imag.fr>
diff --git a/contrib/stats/mailmap.pl b/contrib/stats/mailmap.pl
index 9513f5e35..469af8240 100755
--- a/contrib/stats/mailmap.pl
+++ b/contrib/stats/mailmap.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use warnings 'all';
 use strict;
diff --git a/contrib/stats/packinfo.pl b/contrib/stats/packinfo.pl
index be188c0f1..51823ac94 100755
--- a/contrib/stats/packinfo.pl
+++ b/contrib/stats/packinfo.pl
@@ -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.
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index cf6fc926a..6d7b6c35d 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use 5.008;
 use strict;
diff --git a/git-archimport.perl b/git-archimport.perl
index 9cb123a07..bb423e781 100755
--- a/git-archimport.perl
+++ b/git-archimport.perl
@@ -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.
diff --git a/git-cvsexportcommit.perl b/git-cvsexportcommit.perl
index d13f02da9..c2ebfb59f 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use 5.008;
 use strict;
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 1e4e65a45..5dcdd8106 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -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.
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index d50c85ed7..3ae5e748b 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 ####
 #### This application is a CVS emulation layer for git.
diff --git a/git-difftool.perl b/git-difftool.perl
index df59bdfe9..a34d0f7fd 100755
--- a/git-difftool.perl
+++ b/git-difftool.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (c) 2009, 2010 David Aguilar
 # Copyright (c) 2012 Tim Henigan
 #
diff --git a/git-relink.perl b/git-relink.perl
index 236a3521a..b51348fa6 100755
--- a/git-relink.perl
+++ b/git-relink.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright 2005, Ryan Anderson <ryan@michonline.com>
 # Distribution permitted under the GPL v2, as distributed
 # by the Free Software Foundation.
diff --git a/git-send-email.perl b/git-send-email.perl
index 068d60b3e..678d823af 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright 2002,2005 Greg Kroah-Hartman <greg@kroah.com>
 # Copyright 2005 Ryan Anderson <ryan@michonline.com>
diff --git a/git-svn.perl b/git-svn.perl
index fa4236478..ae3991524 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 # Copyright (C) 2006, Eric Wong <normalperson@yhbt.net>
 # License: GPL v2 or later
 use 5.008;
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7cf68f07b..d084360e6 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 # gitweb - simple web interface to track changes in git repositories
 #
diff --git a/t/Git-SVN/Utils/can_compress.t b/t/Git-SVN/Utils/can_compress.t
index d7b49b8d5..0cdedb25b 100755
--- a/t/Git-SVN/Utils/can_compress.t
+++ b/t/Git-SVN/Utils/can_compress.t
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
diff --git a/t/Git-SVN/Utils/fatal.t b/t/Git-SVN/Utils/fatal.t
index 49e143829..75aaf1633 100755
--- a/t/Git-SVN/Utils/fatal.t
+++ b/t/Git-SVN/Utils/fatal.t
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
diff --git a/t/check-non-portable-shell.pl b/t/check-non-portable-shell.pl
index b170cbc04..3c3e2e7d4 100755
--- a/t/check-non-portable-shell.pl
+++ b/t/check-non-portable-shell.pl
@@ -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
diff --git a/t/gitweb-lib.sh b/t/gitweb-lib.sh
index d5dab5a94..b23843ff4 100644
--- a/t/gitweb-lib.sh
+++ b/t/gitweb-lib.sh
@@ -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
 
diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl
index 924b19dab..2c6278ca6 100755
--- a/t/perf/aggregate.perl
+++ b/t/perf/aggregate.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use lib '../../perl/blib/lib';
 use strict;
diff --git a/t/perf/min_time.perl b/t/perf/min_time.perl
index c1a2717e0..2595eae61 100755
--- a/t/perf/min_time.perl
+++ b/t/perf/min_time.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 my $minrt = 1e100;
 my $min;
diff --git a/t/t0202/test.pl b/t/t0202/test.pl
index 2cbf7b959..d8e967bbc 100755
--- a/t/t0202/test.pl
+++ b/t/t0202/test.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 use 5.008;
 use lib (split(/:/, $ENV{GITPERLLIB}));
 use strict;
diff --git a/t/t4034/perl/post b/t/t4034/perl/post
index e8b72ef5d..87500971d 100644
--- a/t/t4034/perl/post
+++ b/t/t4034/perl/post
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 
diff --git a/t/t4034/perl/pre b/t/t4034/perl/pre
index f6610d37b..5ab5aa42f 100644
--- a/t/t4034/perl/pre
+++ b/t/t4034/perl/pre
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 
diff --git a/t/t9000/test.pl b/t/t9000/test.pl
index dfeaa9c65..4e47f3887 100755
--- a/t/t9000/test.pl
+++ b/t/t9000/test.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 use lib (split(/:/, $ENV{GITPERLLIB}));
 
 use 5.008;
diff --git a/t/t9500-gitweb-standalone-no-errors.sh b/t/t9500-gitweb-standalone-no-errors.sh
index 6d06ed96c..d8b5622b5 100755
--- a/t/t9500-gitweb-standalone-no-errors.sh
+++ b/t/t9500-gitweb-standalone-no-errors.sh
@@ -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"'
diff --git a/t/t9700/test.pl b/t/t9700/test.pl
index 1b75c9196..c0be7e895 100755
--- a/t/t9700/test.pl
+++ b/t/t9700/test.pl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 use lib (split(/:/, $ENV{GITPERLLIB}));
 
 use 5.008;
diff --git a/t/test-terminal.perl b/t/test-terminal.perl
index 96b6a03e1..d1d40c0db 100755
--- a/t/test-terminal.perl
+++ b/t/test-terminal.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 use 5.008;
 use strict;
 use warnings;
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/2] Use env for all perl invocations
  2017-01-12  5:51 [PATCH 0/2] Use env for all perl invocations Pat Pannuto
  2017-01-12  5:51 ` [PATCH 1/2] Convert all 'perl -w' to 'perl' + 'use warnings;' Pat Pannuto
  2017-01-12  5:51 ` [PATCH 2/2] Use 'env' to find perl instead of fixed path Pat Pannuto
@ 2017-01-12  6:21 ` Junio C Hamano
  2017-01-12  7:13   ` Pat Pannuto
  2 siblings, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2017-01-12  6:21 UTC (permalink / raw)
  To: Pat Pannuto; +Cc: git

Pat Pannuto <pat.pannuto@gmail.com> writes:

> 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/perl

would help?

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-12  5:51 ` [PATCH 2/2] Use 'env' to find perl instead of fixed path Pat Pannuto
@ 2017-01-12  6:27   ` Johannes Sixt
  2017-01-12  7:17     ` Pat Pannuto
  0 siblings, 1 reply; 24+ messages in thread
From: Johannes Sixt @ 2017-01-12  6:27 UTC (permalink / raw)
  To: Pat Pannuto; +Cc: gitster, git

Am 12.01.2017 um 06:51 schrieb Pat Pannuto:
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index cf6fc926a..6d7b6c35d 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -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


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/2] Use env for all perl invocations
  2017-01-12  6:21 ` [PATCH 0/2] Use env for all perl invocations Junio C Hamano
@ 2017-01-12  7:13   ` Pat Pannuto
  2017-01-12  8:21     ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Pat Pannuto @ 2017-01-12  7:13 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

[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?

On Thu, Jan 12, 2017 at 1:21 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Pat Pannuto <pat.pannuto@gmail.com> writes:
>
>> 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/perl
>
> would help?

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-12  6:27   ` Johannes Sixt
@ 2017-01-12  7:17     ` Pat Pannuto
  2017-01-12 10:21       ` Johannes Schindelin
  0 siblings, 1 reply; 24+ messages in thread
From: Pat Pannuto @ 2017-01-12  7:17 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Junio C Hamano, git

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?

On Thu, Jan 12, 2017 at 1:27 AM, Johannes Sixt <j6t@kdbg.org> wrote:
> Am 12.01.2017 um 06:51 schrieb Pat Pannuto:
>>
>> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
>> index cf6fc926a..6d7b6c35d 100755
>> --- a/git-add--interactive.perl
>> +++ b/git-add--interactive.perl
>> @@ -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
>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 0/2] Use env for all perl invocations
  2017-01-12  7:13   ` Pat Pannuto
@ 2017-01-12  8:21     ` Junio C Hamano
  0 siblings, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2017-01-12  8:21 UTC (permalink / raw)
  To: Pat Pannuto; +Cc: git

Pat Pannuto <pat.pannuto@gmail.com> writes:

> 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.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-12  7:17     ` Pat Pannuto
@ 2017-01-12 10:21       ` Johannes Schindelin
  2017-01-12 20:40         ` Junio C Hamano
  0 siblings, 1 reply; 24+ messages in thread
From: Johannes Schindelin @ 2017-01-12 10:21 UTC (permalink / raw)
  To: Pat Pannuto; +Cc: Johannes Sixt, Junio C Hamano, git

Hi Pat,

On Thu, 12 Jan 2017, Pat Pannuto wrote:

> 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?

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-12 10:21       ` Johannes Schindelin
@ 2017-01-12 20:40         ` Junio C Hamano
  2017-01-12 21:01           ` Pat Pannuto
  0 siblings, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2017-01-12 20:40 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Pat Pannuto, Johannes Sixt, git

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

> 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.


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-12 20:40         ` Junio C Hamano
@ 2017-01-12 21:01           ` Pat Pannuto
  2017-01-12 21:49             ` Junio C Hamano
                               ` (2 more replies)
  0 siblings, 3 replies; 24+ messages in thread
From: Pat Pannuto @ 2017-01-12 21:01 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Johannes Schindelin, Johannes Sixt, git

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

On Thu, Jan 12, 2017 at 3:40 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>
>> 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.
>

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-12 21:01           ` Pat Pannuto
@ 2017-01-12 21:49             ` Junio C Hamano
  2017-01-13  2:48             ` Eric Wong
  2017-01-13 15:21             ` Johannes Schindelin
  2 siblings, 0 replies; 24+ messages in thread
From: Junio C Hamano @ 2017-01-12 21:49 UTC (permalink / raw)
  To: Pat Pannuto; +Cc: Johannes Schindelin, Johannes Sixt, git

Pat Pannuto <pat.pannuto@gmail.com> writes:

> 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.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-12 21:01           ` Pat Pannuto
  2017-01-12 21:49             ` Junio C Hamano
@ 2017-01-13  2:48             ` Eric Wong
  2017-01-13 15:27               ` Johannes Schindelin
  2017-01-13 18:27               ` Junio C Hamano
  2017-01-13 15:21             ` Johannes Schindelin
  2 siblings, 2 replies; 24+ messages in thread
From: Eric Wong @ 2017-01-13  2:48 UTC (permalink / raw)
  To: Pat Pannuto; +Cc: Junio C Hamano, Johannes Schindelin, Johannes Sixt, git

Pat Pannuto <pat.pannuto@gmail.com> wrote:
> 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.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-12 21:01           ` Pat Pannuto
  2017-01-12 21:49             ` Junio C Hamano
  2017-01-13  2:48             ` Eric Wong
@ 2017-01-13 15:21             ` Johannes Schindelin
  2 siblings, 0 replies; 24+ messages in thread
From: Johannes Schindelin @ 2017-01-13 15:21 UTC (permalink / raw)
  To: Pat Pannuto; +Cc: Junio C Hamano, Johannes Sixt, git

Hi Pat,

On Thu, 12 Jan 2017, Pat Pannuto wrote:

> 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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-13  2:48             ` Eric Wong
@ 2017-01-13 15:27               ` Johannes Schindelin
  2017-01-13 16:58                 ` Eric Wong
  2017-01-13 18:27               ` Junio C Hamano
  1 sibling, 1 reply; 24+ messages in thread
From: Johannes Schindelin @ 2017-01-13 15:27 UTC (permalink / raw)
  To: Eric Wong; +Cc: Pat Pannuto, Junio C Hamano, Johannes Sixt, git

Hi Eric,

On Fri, 13 Jan 2017, Eric Wong wrote:

> Pat Pannuto <pat.pannuto@gmail.com> wrote:
> > 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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-13 15:27               ` Johannes Schindelin
@ 2017-01-13 16:58                 ` Eric Wong
  2017-01-13 17:13                   ` Johannes Schindelin
  0 siblings, 1 reply; 24+ messages in thread
From: Eric Wong @ 2017-01-13 16:58 UTC (permalink / raw)
  To: Johannes Schindelin; +Cc: Pat Pannuto, Junio C Hamano, Johannes Sixt, git

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> 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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-13 16:58                 ` Eric Wong
@ 2017-01-13 17:13                   ` Johannes Schindelin
  0 siblings, 0 replies; 24+ messages in thread
From: Johannes Schindelin @ 2017-01-13 17:13 UTC (permalink / raw)
  To: Eric Wong; +Cc: Pat Pannuto, Junio C Hamano, Johannes Sixt, git

Hi Eric,

On Fri, 13 Jan 2017, Eric Wong wrote:

> Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:
> > 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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-13  2:48             ` Eric Wong
  2017-01-13 15:27               ` Johannes Schindelin
@ 2017-01-13 18:27               ` Junio C Hamano
  2017-01-13 18:52                 ` Eric Wong
  1 sibling, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2017-01-13 18:27 UTC (permalink / raw)
  To: Eric Wong; +Cc: Pat Pannuto, Johannes Schindelin, Johannes Sixt, git

Eric Wong <e@80x24.org> writes:

> Pat Pannuto <pat.pannuto@gmail.com> wrote:
>> 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.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-13 18:27               ` Junio C Hamano
@ 2017-01-13 18:52                 ` Eric Wong
  2017-01-13 20:01                   ` Junio C Hamano
  2017-01-14  7:54                   ` Jeff King
  0 siblings, 2 replies; 24+ messages in thread
From: Eric Wong @ 2017-01-13 18:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Pat Pannuto, Johannes Schindelin, Johannes Sixt, git

Junio C Hamano <gitster@pobox.com> wrote:
> Eric Wong <e@80x24.org> writes:
> > Pat Pannuto <pat.pannuto@gmail.com> wrote:
> >> 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.

Yes.  "use warnings" should be in our own libs in case other
people run without "-w"

> 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.

> 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;
...

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-13 18:52                 ` Eric Wong
@ 2017-01-13 20:01                   ` Junio C Hamano
  2017-01-13 21:39                     ` Eric Wong
  2017-01-14  7:54                   ` Jeff King
  1 sibling, 1 reply; 24+ messages in thread
From: Junio C Hamano @ 2017-01-13 20:01 UTC (permalink / raw)
  To: Eric Wong; +Cc: Pat Pannuto, Johannes Schindelin, Johannes Sixt, git

Eric Wong <e@80x24.org> writes:

> Junio C Hamano <gitster@pobox.com> wrote:
>> Eric Wong <e@80x24.org> writes:
>> > Pat Pannuto <pat.pannuto@gmail.com> wrote:
>> >> 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.
>
> 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, "-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;
> ...

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.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-13 20:01                   ` Junio C Hamano
@ 2017-01-13 21:39                     ` Eric Wong
  0 siblings, 0 replies; 24+ messages in thread
From: Eric Wong @ 2017-01-13 21:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Pat Pannuto, Johannes Schindelin, Johannes Sixt, git

Junio C Hamano <gitster@pobox.com> wrote:
> Eric Wong <e@80x24.org> writes:
> > Junio C Hamano <gitster@pobox.com> wrote:
> >> Eric Wong <e@80x24.org> writes:
> >> > Pat Pannuto <pat.pannuto@gmail.com> wrote:
> >> >> 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.
> >
> > 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.

> 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.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-13 18:52                 ` Eric Wong
  2017-01-13 20:01                   ` Junio C Hamano
@ 2017-01-14  7:54                   ` Jeff King
  2017-01-14 10:31                     ` Eric Wong
  1 sibling, 1 reply; 24+ messages in thread
From: Jeff King @ 2017-01-14  7:54 UTC (permalink / raw)
  To: Eric Wong
  Cc: Junio C Hamano, Pat Pannuto, Johannes Schindelin, Johannes Sixt,
	git

On Fri, Jan 13, 2017 at 06:52:46PM +0000, Eric Wong wrote:

> > 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;
> ...

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

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-14  7:54                   ` Jeff King
@ 2017-01-14 10:31                     ` Eric Wong
  2017-01-14 21:57                       ` brian m. carlson
  0 siblings, 1 reply; 24+ messages in thread
From: Eric Wong @ 2017-01-14 10:31 UTC (permalink / raw)
  To: Jeff King
  Cc: Junio C Hamano, Pat Pannuto, Johannes Schindelin, Johannes Sixt,
	git

Jeff King <peff@peff.net> wrote:
> 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.

> 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.

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/2] Use 'env' to find perl instead of fixed path
  2017-01-14 10:31                     ` Eric Wong
@ 2017-01-14 21:57                       ` brian m. carlson
  0 siblings, 0 replies; 24+ messages in thread
From: brian m. carlson @ 2017-01-14 21:57 UTC (permalink / raw)
  To: Eric Wong
  Cc: Jeff King, Junio C Hamano, Pat Pannuto, Johannes Schindelin,
	Johannes Sixt, git

[-- Attachment #1: Type: text/plain, Size: 2488 bytes --]

On Sat, Jan 14, 2017 at 10:31:34AM +0000, Eric Wong wrote:
> Jeff King <peff@peff.net> wrote:
> > 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).

My experience is that using strict and warnings is so common in Perl
code that absent a compelling documented reason, most Perl developers
would consider it a bug not to use them.  Consequently, using -w, while
a good practice, is unlikely to have any practical effect on external
modules.

What is more likely to occur is that as newer versions of Perl come out,
we'll get warnings about questionable constructs that Perl, in its
extensive flexibility, has permitted for a long time, but should really
be fixed.  Most distributors of Git will have fixed any affected
third-party modules as part of the Perl upgrade,

> 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.

I'm working on patches for USE_ASCIIDOCTOR=Yes and I found at least two
bugs by enabling warnings.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2017-01-14 21:57 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-12  5:51 [PATCH 0/2] Use env for all perl invocations Pat Pannuto
2017-01-12  5:51 ` [PATCH 1/2] Convert all 'perl -w' to 'perl' + 'use warnings;' Pat Pannuto
2017-01-12  5:51 ` [PATCH 2/2] Use 'env' to find perl instead of fixed path Pat Pannuto
2017-01-12  6:27   ` Johannes Sixt
2017-01-12  7:17     ` Pat Pannuto
2017-01-12 10:21       ` Johannes Schindelin
2017-01-12 20:40         ` Junio C Hamano
2017-01-12 21:01           ` Pat Pannuto
2017-01-12 21:49             ` Junio C Hamano
2017-01-13  2:48             ` Eric Wong
2017-01-13 15:27               ` Johannes Schindelin
2017-01-13 16:58                 ` Eric Wong
2017-01-13 17:13                   ` Johannes Schindelin
2017-01-13 18:27               ` Junio C Hamano
2017-01-13 18:52                 ` Eric Wong
2017-01-13 20:01                   ` Junio C Hamano
2017-01-13 21:39                     ` Eric Wong
2017-01-14  7:54                   ` Jeff King
2017-01-14 10:31                     ` Eric Wong
2017-01-14 21:57                       ` brian m. carlson
2017-01-13 15:21             ` Johannes Schindelin
2017-01-12  6:21 ` [PATCH 0/2] Use env for all perl invocations Junio C Hamano
2017-01-12  7:13   ` Pat Pannuto
2017-01-12  8:21     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).