[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Generic mechanism to detect shell features
From: |
Paolo Bonzini |
Subject: |
Re: [PATCH] Generic mechanism to detect shell features |
Date: |
Tue, 13 Jan 2004 00:12:56 +0100 |
> Did you have a look at Eric Sunshine's _AS_SHELL_BEST proposal?
No, I noted it a few hours after posting mine.
> I haven't had time to review either proposal thoroughly, but a quick
> glance suggests that the _AS_SHELL_BEST patch is a bit more polished
Surely.
> and better fixes the bugs discussed in the "Shell function reporting" thread
Both do (or at least should, I could not test on a bad shell).
> <http://mail.gnu.org/archive/html/autoconf-patches/2004-01/threads.html#00014>,
> but your _AS_DETECT_BETTER_SHELL proposal has the nicer idea of a
> generic detection mechanism.
And of the death of AS_INIT_WITH_SHELL_FN and of all the temporary bits of
m4sh.m4
(they are all condensed in AS_SHELL_FN_SPY).
> Ideally we'd see a single proposal that does both.
I'd agree with applying Eric's patch and working incrementally from there. What
follows is a brief review:
+AS_IF([test $as_fn_exitcode -eq 0],
+ m4_ifval([$1], [$1], [:]),
+ m4_ifval([$2], [$2], [:]))
+])# _AS_SHELL_FN_WORKS
The idea of AS_IF is to avoid those m4_ifvals, just do AS_IF([...], [$1], [$2]).
+_AS_SHELL_FN_SUPPORTED && as_shell_func=x
+_AS_LINENO_WORKS && as_shell_lineno=x
Use _AS_SHELL_FN_SUPPORTED_FOR_SHELL([$SHELL]) in case the syntax is not
supported,
and drop _AS_SHELL_FN_SUPPORTED. I also suggest that you do
CONFIG_SHELL="$SHELL"
_AS_SHELL_FN_SUPPORTED && as_shell_func="$SHELL"
_AS_LINENO_WORKS && as_shell_lineno="$SHELL"
This way, ...
+ x|'') m4_default([$1]) ;;
+ *) m4_default([$2]) ;;
... you can drop as_shell_best, use CONFIG_SHELL instead, then just do
AS_IF([test
"$CONFIG_SHELL" = "$SHELL"], [$1], [$2]).
+# Find the most desirable shell for running this script.
+AS_IF([test -z "$CONFIG_SHELL"],
+ [_AS_SHELL_BEST([],
+ [AS_UNSET([BASH_ENV])
+ AS_UNSET([ENV])
+ CONFIG_SHELL=$as_shell_best
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}],
+ [$1])])
(Of course, don't assign CONFIG_SHELL here).
Otherwise looks great.
Paolo
Re: [PATCH] Generic mechanism to detect shell features, Eric Sunshine, 2004/01/12