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

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

From
Jeff King <peff@peff.net>
Date
Apr 17, 2010, 17:55 UTC
Message-ID
<20100417175553.GC23642@coredump.intra.peff.net>
In-Reply-To
<20100417170500.GA4587@comcast.net>
On Sat, Apr 17, 2010 at 11:05:00AM -0600, Matthew Ogilvie wrote:
Show 7 quoted lines
> Yes, "perl -cw"'s exit code is always good, but the standard error is
> needlessly noisy in the success case:
> 
>   $ perl -cw -e 'print "hi\n"'
>   -e syntax OK
>   $ echo $?
>   0
Ah, OK. I misunderstood what you were trying to do before.
> 1. Accept the noise output from make and perl.  If we are willing to
>    accept this, then a simpler and/or uncoditional patch would be fine.

Though I would prefer it silenced, I don't personally have a big problem with this. I guess others might.

Show 11 quoted lines
> 2. Filter out the "{scriptName} syntax OK" noise with grep (or sed),
>    but then $? is grep's status (not perl's), and you have to go
>    through contortions to properly test perl's status:
> 
>     2a. Use PIPESTATUS, but this is a non-portable bashism.
>         My current version of the patch elects to do this, but
>         leaves the check disabled to (hopefully) avoid portability
>         issues.  (A second advantage of leaving it disabled [or at
>         least disablable] is if someone is in a cross-compile
>         environment and the target perl path is different 
>         from the build perl path.)

Hmm. The cross-compilation thing is interesting, but I'm not sure it even works now. We already are relying on generating perl.mak and using it as part of our build, I think. I haven't looked closely at the perl build stuff in git, though, so maybe there is a way to make it work.

>     2b. Use a portable technique that involves echoing the status
>         redirected to file descriptor 3, then pulling the status out
>         of file descriptor 3 outside the pipeline.  This is frankly
>         kind of complicated and hard to read.

Yeah, I have used that technique before, and it is unreadable. Maybe simpler is to cheat with a tempfile:

  if ! perl -wc $@+ 2>$@.stderr; \
    then cat >&2 $@.stderr; rm -f $@.stderr; exit 1; \
    else rm -f $@.stderr; fi && \
but that is getting a bit unreadable, too. I dunno.
-Peff
Previous: Matthew Ogilvie
Message 4 of 4 in “Makefile: Check for perl script errors with perl -c”
  1. Makefile: Check for perl script errors with perl -cMatthew Ogilvie, Apr 17, 2010
  2. Jeff KingApr 17, 2010
  3. Matthew OgilvieApr 17, 2010
  4. Jeff KingApr 17, 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.