[Top][All Lists]

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

Re: more efficient AS_EXIT

From: Ralf Wildenhues
Subject: Re: more efficient AS_EXIT
Date: Tue, 18 Nov 2008 20:15:03 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

Hi Eric,

* Eric Blake wrote on Tue, Nov 18, 2008 at 06:03:51PM CET:
> >  It could
> > be more of a reduction, if we were willing to shorten the function names
> > to as_exit (I'm okay with exceptions to the rule of thumb about the
> > as_func_* namespace, as long as we have a good reason for it and aren't
> > worried about inadvertant namespace clashes - for that matter, since we
> > own the entire as_* namespace and the user should always be going through
> > our macros unless we document a variable name, maybe we can get away with
> > shortening all of our macro names).
> Autoconf had already been using 'ac_func_list' for AC_CHECK_FUNCS_ONCE, which 
> clashes with our current choice of namespace a[cst]_func_.  If no one 
> complains, I will commit the second patch below tomorrow; it is a purely 
> mechanical replacement to the shorter a[cst]_fn_ for shell functions, leaving 
> ac_func_list for the list of C functions being checked (and in general, 
> leaving 
> the term "func" to refer to language functions linked by the compiler, and 
> "fn" 
> for functions in the shell script).  It shaves nearly 2k off of coreutils' 
> configure, and more than 27k off of autoconf's testsuite (almost 1%!).

OK with me, but please do not name functions outside a[cst]_fn_.  That
allows us to remember mechanically that there are shells which do not
provide separate namespaces for functions and variables.

> address@hidden
> +$ @kbd{bash -c 'trap '\''echo $?'\'' 0; set -e; false'}
> +1
> +$ @kbd{sh -c 'trap '\''echo $?'\'' 0; set -e; false'}
> +0
> address@hidden example
> +
> address@hidden
> +Thus, when writing a script in M4sh, rather than trying to rely on
> address@hidden -e}, it is better to append @samp{|| AS_EXIT([$?])} to any
> +statement where it is desirable to abort on failure.

Hmm.  How about 'append @samp{|| AS_EXIT}' and make AS_EXIT use
m4_default([$1], [$?])?  Current documented default is 1, and a couple
of places in Autoconf exploit that, but I wonder whether $? would be a
more consistent one: that's the default of `exit' (except for
portability warts).

> address@hidden AS_SET_STATUS (@var{status})
> address@hidden
> +Emit shell code to set the value of @samp{$?} to @var{status} without
> +forking.

Why guarantee that it does not fork?  But ok, I guess.

>  However, this is not guaranteed to abort a shell running with
> address@hidden -e} (@pxref{Limitations of Builtins, , Limitations of Shell
> +Builtins}).

I still wonder whether this can be worked around (or is that overkill?).


reply via email to

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