From: Jeff King <peff@peff.net>
To: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
Cc: git@vger.kernel.org, gitster@pobox.com
Subject: Re: [PATCH] Makefile: Check for perl script errors with perl -c
Date: Sat, 17 Apr 2010 03:27:21 -0400 [thread overview]
Message-ID: <20100417072721.GD10365@coredump.intra.peff.net> (raw)
In-Reply-To: <1271471380-17701-1-git-send-email-mmogilvi_git@miniinfo.net>
On Fri, Apr 16, 2010 at 08:29:40PM -0600, Matthew Ogilvie wrote:
> I'm not sure anyone will think this is worth including, but I'm
> used to "make" (and the compiler) detecting trivial errors
> in compiled langauges, and was getting annoyed that it wasn't
> doing something similar for perl scripts (especially since in git you
> are really expected to "make" the scripts anyway).
I usually do the same thing in my perl makefiles, so I would find it
useful.
> The whole tradeoff between noise ("{script} syntax OK"), portability
> (PIPESTATUS is a bashism), or really ugly contortions with redirecting
> extra file descriptors (to avoid PIPESTATUS) seems to be the biggest
> downside of the idea behind this patch.
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
> @@ -1553,6 +1557,14 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
> -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
> $@.perl >$@+ && \
> chmod +x $@+ && \
> + if test x"$(USE_PERL_CHECK)" != x"" ; then \
> + '$(PERL_PATH_SQ)' -cw $@+ 2>&1 | grep -v '^$@+ syntax OK$$' 1>&2 ; \
> + perlStat="$${PIPESTATUS[0]}" && \
> + if test x"$$perlStat" != x"0" ; then \
> + echo '"$(PERL_PATH_SQ) -c $@+" failed' 1>&2 ; \
> + exit "$$perlStat" ; \
> + fi ; \
> + fi && \
> mv $@+ $@
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
next prev parent reply other threads:[~2010-04-17 7:27 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-17 2:29 [PATCH] Makefile: Check for perl script errors with perl -c Matthew Ogilvie
2010-04-17 7:27 ` Jeff King [this message]
2010-04-17 17:05 ` Matthew Ogilvie
2010-04-17 17:55 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100417072721.GD10365@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=mmogilvi_git@miniinfo.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox