help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to stop building when sub-make returns error


From: Maxim Yegorushkin
Subject: Re: How to stop building when sub-make returns error
Date: Tue, 12 Jan 2010 21:43:35 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.5) Gecko/20091209 Fedora/3.0-4.fc12 Thunderbird/3.0

On 12/01/10 18:07, Philip Guenther wrote:
On Tue, Jan 12, 2010 at 9:21 AM, Paul Smith<address@hidden>  wrote:
On Tue, 2010-01-12 at 11:17 -0500, Harvey Chapman wrote:
For more information on pipes and errors, search for "pipefail" in the
bash man page. http://linux.die.net/man/1/bash
...
If you care anything about portability in your makefile, please do NOT
write your recipes to rely on bash features such as pipefail.  Even if
you don't care about portability and do write your recipes to use bash
features, you need to add SHELL=/bin/bash to your makefile so everyone
will understand that you're requiring it.

For those wondering how to portably  implement "run make, filtering
its stdout and stderr through grep, but returning the exit status of
make", the classical method (as I learned it) is to pass the return
code down an additional pipe, redirected to some other file
descriptor:

two:
         { { $(MAKE) error 2>&1; echo $$?>&3 ; } | grep error>&2 ; }
3>&1 | { read ret; exit $$ret; }

That passes the error status down a pipe on fd 3 'around' the grep and
to a separate pipe where it's picked up by the read and give to the
exit command to set the entire pipe's exit status.  Yeah, it's ugly,
but it works everywhere.

Why not simply:

  $(MAKE) error 2>&1 | grep error; exit ${PIPESTATUS[0]}

?

--
Max





reply via email to

[Prev in Thread] Current Thread [Next in Thread]