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

[PATCH] perl: use "use warnings" instead of -w

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Sep 24, 2010, 20:00 UTC
Message-ID
<1285358453-19292-2-git-send-email-avarab@gmail.com>
In-Reply-To
<AANLkTikp0mkFHYCdgqThfoFr3VkVECDmW6qE3+DSSHaq@mail.gmail.com>

Change the Perl scripts to turn on lexical warnings instead of setting the global $^W variable via the -w switch.

The -w sets warnings for all code that interpreter runs, while "use warnings" is lexically scoped. The former is probably not what the authors wanted.

As an auxiliary benefit it's now possible to build Git with:
    PERL_PATH='/usr/bin/env perl'

Which would previously result in failures, since "#!/usr/bin/env perl -w" doesn't work as a shebang.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---

This is a re-send, it's independent of bumping the version to 5.8 (use warnings was introduced in 5.6), but a good idea anyway.

 contrib/examples/git-svnimport.perl         |    2 +-
 contrib/fast-import/import-directories.perl |    3 ++-
 git-add--interactive.perl                   |    3 ++-
 git-archimport.perl                         |    2 +-
 git-cvsexportcommit.perl                    |    3 ++-
 git-cvsimport.perl                          |    2 +-
 git-send-email.perl                         |    2 +-
 7 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/contrib/examples/git-svnimport.perl b/contrib/examples/git-svnimport.perl
index 4576c4a..ead4c04 100755
--- a/contrib/examples/git-svnimport.perl
+++ b/contrib/examples/git-svnimport.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/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/import-directories.perl b/contrib/fast-import/import-directories.perl
index 3a5da4a..7f3afa5 100755
--- a/contrib/fast-import/import-directories.perl
+++ b/contrib/fast-import/import-directories.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 #
 # Copyright 2008-2009 Peter Krefting <peter@softwolves.pp.se>
 #
@@ -140,6 +140,7 @@ by whitespace or other characters.
 
 # Globals
 use strict;
+use warnings;
 use integer;
 my $crlfmode = 0;
 my @revs;
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index a96fb53..77f60fa 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1,7 +1,8 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use 5.008;
 use strict;
+use warnings;
 use Git;
 
 binmode(STDOUT, ":raw");
diff --git a/git-archimport.perl b/git-archimport.perl
index 947638c..bc32f18 100755
--- a/git-archimport.perl
+++ b/git-archimport.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/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 9a8188b..39a426e 100755
--- a/git-cvsexportcommit.perl
+++ b/git-cvsexportcommit.perl
@@ -1,7 +1,8 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 use 5.008;
 use strict;
+use warnings;
 use Getopt::Std;
 use File::Temp qw(tempdir);
 use Data::Dumper;
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 53869fb..249aeaf 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 
 # This tool is copyright (c) 2005, Matthias Urlichs.
 # It is released under the Gnu Public License, version 2.
diff --git a/git-send-email.perl b/git-send-email.perl
index 314e59e..d10d869 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1,4 +1,4 @@
-#!/usr/bin/perl -w
+#!/usr/bin/perl
 #
 # Copyright 2002,2005 Greg Kroah-Hartman <greg@kroah.com>
 # Copyright 2005 Ryan Anderson <ryan@michonline.com>
-- 
1.7.3.256.g00e8a
Previous: Tom G. Christensen
Message 18 of 18 in “Let's bump the minimum Perl version to 5.8”
  1. Ævar Arnfjörð BjarmasonSep 24, 2010
  2. Tor ArntsenSep 24, 2010
  3. Ævar Arnfjörð BjarmasonSep 24, 2010
  4. Andreas EricssonSep 24, 2010
  5. Ævar Arnfjörð BjarmasonSep 24, 2010
  6. Andreas EricssonSep 26, 2010
  7. Tor ArntsenSep 24, 2010
  8. Brian GernhardtSep 24, 2010
  9. Tom G. ChristensenSep 27, 2010
  10. Pascal ObrySep 24, 2010
  11. Joshua JuranSep 24, 2010
  12. Randal L. SchwartzSep 24, 2010
  13. Ævar Arnfjörð BjarmasonSep 24, 2010
  14. Randal L. SchwartzSep 24, 2010
  15. perl: bump the required Perl version to 5.8 from 5.6.[21]Ævar Arnfjörð Bjarmason, Sep 24, 2010
  16. Tor ArntsenSep 26, 2010
  17. Tom G. ChristensenSep 27, 2010
  18. perl: use "use warnings" instead of -wÆvar Arnfjörð Bjarmason, Sep 24, 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.