help-make
[Top][All Lists]
Advanced

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

Re: How to stop make when an error occurs in a for loop?


From: Paul Smith
Subject: Re: How to stop make when an error occurs in a for loop?
Date: Tue, 19 Jul 2011 09:52:48 -0400

On Tue, 2011-07-19 at 15:23 +0200, Warlich, Christof wrote:
> all:
>     @for i in false true; do\
>         if ! eval $$i; then\
>             echo We leave the loop when $$i is called, but ...;\
>             false;\
>             break;\
>         fi;\
>     done;
>     @echo ... the exit status is always $$?. So how can I cause make\
>                 to stop when a failure occurs inside a for loop?;
> $ make
> We leave the loop when false is called, but ...
> ... the exit status is always 0.

The exit status is the exit code of the final program, unless you exit
early.  The exit code of "break" is not an error.

> So how can I cause make to stop when a failure occurs inside a for
> loop?

Use "exit 1" instead of "false; break;"

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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