[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: make does not stop when a command returns an error
From: |
Paul Smith |
Subject: |
Re: make does not stop when a command returns an error |
Date: |
Thu, 08 Mar 2007 21:35:49 -0500 |
On Thu, 2007-03-08 at 20:26 +0100, Torsten Mohr wrote:
> Hi,
>
> i think i need to track this down a bit further, but can anybody
> see why "make" should continue to go even when i call a perl
> script in a rule and that script does an "exit(-1)" ?
>
> In front of that rule i don't have any "-".
If you showed us the rule we could be a lot more help.
Without any further information, we can't say for sure; we can only
guess. One common mistake is that the command that fails is not the
last command in the script that make runs, so make doesn't see it. For
example, if you have:
foo:
perl -e myscript; do_something_else
then if the perl command fails make doesn't see that; make will only see
the exit code of the do_something_else command. If you have multiple
commands in make you should ALWAYS either put them on separate lines:
foo:
perl -e myscript
do_something_else
or else if you don't want to do that you should use the && operator
between all your commands:
foo:
perl -e myscript && do_something_else
Another problem, that is much harder to solve, is pipes: the shell will
use the exit code of the final command as the exit of the shell, so:
foo:
perl -e myscript | do_something_else
also won't see any exit code from the perl script.
--
-------------------------------------------------------------------------------
Paul D. Smith <address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist