autoconf-patches
[Top][All Lists]
Advanced

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

Re: more efficient AS_EXIT


From: Eric Blake
Subject: Re: more efficient AS_EXIT
Date: Wed, 19 Nov 2008 15:50:00 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Paolo Bonzini <bonzini <at> gnu.org> writes:

> >> Well, as AS_EXIT was previously undocumented, I am comfortable making that
> >> change.  It does seem like making $? instead of 1 is a better default,
> >> even if it might make some scripts in the wild start returning 0.
> > 
> > Even better: if AS_EXIT is called with arguments, exit with $? unless it
> > is 0, in which case, exit with status 1.
> 
> ???
> 
> No, please... we are lucky enough:
> Our own m4sh.m4 is the only user of AS_EXIT without arguments.

Just for the record:

The _only_ place where AS_EXIT changed semantics from what
it had in 2.63 to what it has now in autoconf.git is if you:
1) use it without arguments, and
2) $? is greater than 1

in which case, you now get $? instead of 1 (generally a
good move; consider if $? is 139 - you want the exit
status of your script to reflect the fact that you aborted
your script due to a prior command aborting with a signal,
rather than always exiting with status 1 no matter what).

Meanwhile, by changing the semantics, we can simplify
our documentation to actually _recommend_ that people
use AS_EXIT without arguments, at least when using
the idiom <command> || AS_EXIT.  Other idioms, such
as trap 's=$?; cleanup; AS_EXIT([$s])' 0, still need to
pass an explicit argument (basically, in the same places
where relying on exit's default of $? is the wrong thing
to do).  And the user can still do AS_EXIT([$?]) if they
really want to exit with 0 status when $? is 0.

-- 
Eric Blake







reply via email to

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