Re: [PATCH] Makefile: Check for perl script errors with perl -c

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeff King
Date: Saturday, April 17, 2010 - 12:27 am

On Fri, Apr 16, 2010 at 08:29:40PM -0600, Matthew Ogilvie wrote:


I usually do the same thing in my perl makefiles, so I would find it
useful.


Why do you need to run it through grep? Doesn't:

  echo 'use strict; bogosity' >foo.pl
  perl -wc foo.pl

properly set the exit code? I get:

  $ perl -wc foo.pl
  Bareword "bogosity" not allowed while "strict subs" in use at foo.pl line 1.
  foo.pl had compilation errors.
  $ echo $?
  255


So something like:

diff --git a/Makefile b/Makefile
index 87c90d6..d9b6613 100644
--- a/Makefile
+++ b/Makefile
@@ -1545,6 +1545,10 @@ $(SCRIPT_LIB) : % : %.sh
 ifndef NO_PERL
 $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
 
+ifdef USE_PERL_CHECK
+PERL_CHECK = perl -wc $@+ &&
+endif
+
 perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL
 	$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
 
@@ -1562,6 +1566,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
 	    -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
 	    $@.perl >$@+ && \
 	chmod +x $@+ && \
+	$(PERL_CHECK) \
 	mv $@+ $@
 
 

You could even just make it unconditional. I don't know that we have an
official policy, but we usually strive for strict, warnings-free perl.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Makefile: Check for perl script errors with perl -c, Matthew Ogilvie, (Fri Apr 16, 7:29 pm)
Re: [PATCH] Makefile: Check for perl script errors with pe ..., Jeff King, (Sat Apr 17, 12:27 am)