git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: [PATCH] perl shebangs: Use /usr/bin/env, not /usr/bin/perl

From
Peter Kjellerstedt <peter.kjellerstedt@axis.com>
Date
May 21, 2010, 15:15 UTC
Message-ID
<A612847CFE53224C91B23E3A5B48BAC74483234EEB@xmail3.se.axis.com>
In-Reply-To
<1274454086-2312-1-git-send-email-avarab@gmail.com>
Show 83 quoted lines
> -----Original Message-----
> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On
> Behalf Of Ævar Arnfjörð Bjarmason
> Sent: den 21 maj 2010 17:01
> To: git@vger.kernel.org
> Cc: Junio C Hamano; Ævar Arnfjörð Bjarmason
> Subject: [PATCH] perl shebangs: Use /usr/bin/env, not /usr/bin/perl
> 
> Change the Perl Git utilities to use #!/usr/bin/env perl as a shebang
> instead of #!/usr/bin/perl. This makes e.g. git-send-email work if
> your personal perl has Net::SMTP::SSL, but your system perl doesn't.
> 
> This only affects shebangs in the uninstalled source tree. On
> installation shebangs will still be munged to PERL_PATH, which is
> currently /usr/bin/perl by default.
> 
> With this change all the code in Git that uses a shebang now uses
> /usr/bin/env, except those things that use /bin/sh and /bin/bash. All
> the Python code already used it, and some of the Perl code.
> 
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
> ---
> 
> This should probably have been a series, not an individual patch since
> it depends on <1274453455-1941-1-git-send-email-avarab@gmail.com> to
> apply. However the two are functionally independent. I can alter this
> one so that it applies to the current master on request, but I'm
> guessing the "perl libs: perl -w + use warnings is redundant" patch is
> wanted anyway.
> 
>  Documentation/build-docdep.perl             |    2 +-
>  Documentation/cat-texi.perl                 |    2 +-
>  Documentation/cmd-list.perl                 |    2 +-
>  Documentation/fix-texi.perl                 |    2 +-
>  compat/vcbuild/scripts/clink.pl             |    2 +-
>  compat/vcbuild/scripts/lib.pl               |    2 +-
>  contrib/blameview/blameview.perl            |    2 +-
>  contrib/buildsystems/engine.pl              |    2 +-
>  contrib/buildsystems/generate               |    2 +-
>  contrib/buildsystems/parse.pl               |    2 +-
>  contrib/continuous/cidaemon                 |    2 +-
>  contrib/continuous/post-receive-cinotify    |    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/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-send-email.perl                         |    2 +-
>  gitweb/gitweb.perl                          |    2 +-
>  t/gitweb-lib.sh                             |    2 +-
>  t/t7006/test-terminal.perl                  |    2 +-
>  t/t9138-git-svn-authors-prog.sh             |    2 +-
>  t/t9700/test.pl                             |    2 +-
>  33 files changed, 33 insertions(+), 33 deletions(-)
> 
> diff --git a/Documentation/build-docdep.perl b/Documentation/build-
> docdep.perl
> index ba4205e..dc50f21 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 828ec62..d96d2f1 100755
> --- a/Documentation/cat-texi.perl
> +++ b/Documentation/cat-texi.perl
> @@ -1,4 +1,4 @@
> -#!/usr/bin/perl -w
> +#!/usr/bin/env perl -w

This does not work. You cannot give arguments to an application started via /usr/bin/env; it will interprete everything after /usr/bin/env as the application name and fail with:

/usr/bin/env: perl -w: No such file or directory
//Peter
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 3 of 10 in “perl libs: perl -w + use warnings is redundant”
  1. perl libs: perl -w + use warnings is redundantÆvar Arnfjörð Bjarmason, May 21, 2010
  2. perl shebangs: Use /usr/bin/env, not /usr/bin/perlÆvar Arnfjörð Bjarmason, May 21, 2010
  3. Peter KjellerstedtMay 21, 2010
  4. Ævar Arnfjörð BjarmasonMay 21, 2010
  5. perl shebangs: Use /usr/bin/env, not /usr/bin/perlÆvar Arnfjörð Bjarmason, May 21, 2010
  6. Tor ArntsenMay 21, 2010
  7. Randal L. SchwartzMay 21, 2010
  8. Jeff KingMay 21, 2010
  9. 1/2 perl libs: perl -w + use warnings is redundantÆvar Arnfjörð Bjarmason, May 21, 2010
  10. Ævar Arnfjörð BjarmasonMay 21, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.