From: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
To: git@vger.kernel.org, gitster@pobox.com
Cc: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
Subject: [PATCH] Makefile: Check for perl script errors with perl -c
Date: Fri, 16 Apr 2010 20:29:40 -0600 [thread overview]
Message-ID: <1271471380-17701-1-git-send-email-mmogilvi_git@miniinfo.net> (raw)
This allows you to notice trivial syntax errors in perl scripts earlier,
for example before running t/* tests that generate a lot of
separate errors.
You have to set USE_PERL_CHECK to enable this, because it uses
the non-standard PIPESTATUS bashism to grep out "{script} syntax OK"
useless noise.
Signed-off-by: Matthew Ogilvie <mmogilvi_git@miniinfo.net>
---
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).
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.
--
Matthew Ogilvie [mmogilvi_git@miniinfo.net]
Makefile | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
index 910f471..1e827bb 100644
--- a/Makefile
+++ b/Makefile
@@ -168,6 +168,10 @@ all::
#
# Define NO_PERL if you do not want Perl scripts or libraries at all.
#
+# Define USE_PERL_CHECK if you want the makefile to run "perl -cw" to
+# check perl scripts for basic errors. This requires that your
+# $SHELL_PATH supports the ${PIPESTATUS[0]} variable, like bash.
+#
# Define NO_PYTHON if you do not want Python scripts or libraries at all.
#
# Define NO_TCLTK if you do not want Tcl/Tk GUI.
@@ -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 $@+ $@
--
1.7.0.GIT
next reply other threads:[~2010-04-17 2:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-17 2:29 Matthew Ogilvie [this message]
2010-04-17 7:27 ` [PATCH] Makefile: Check for perl script errors with perl -c Jeff King
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=1271471380-17701-1-git-send-email-mmogilvi_git@miniinfo.net \
--to=mmogilvi_git@miniinfo.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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