help-make
[Top][All Lists]
Advanced

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

Re: ignore errors on specific command


From: David Boyce
Subject: Re: ignore errors on specific command
Date: Wed, 31 Mar 2010 07:01:36 -0400

On Wed, Mar 31, 2010 at 5:16 AM, Stephan Beal
<address@hidden> wrote:
> The return value of cmd2 WILL be ignored here.

Note, however, that this is a temporary/non-portable phenomenon.
According to the recently clarified POSIX standard, make is in fact
supposed to abort if such an "internal" command failure occurs. GNU
make has historically not done so but other make programs do and GNU
make's next release (3.82) will have to conform. So this would be a
good time to code defensively and not assume the current behavior.

> That said, you can explicitly force the return code to be 0 with:
> all:
>     cmd1 ; cmd2 || true ; cmd3

Minor point, but there's a shell builtin ":" which does the same thing
and is faster and more robust (it works natively on Windows, for one
thing). I wrote up a (modestly titled) "Shell Scripter's Bible" long
ago for people I worked with and one of the entries said that it's a
good idea to think of ||: as a special atomic shell operator meaning
"ignore previous exit code". Not literally true, of course, but a
handy mnemonic. If you change SHELL you may need to use 'true' but
with the default shell ':' is better.

David Boyce




reply via email to

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