[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
shell function spy update
From: |
Ralf Wildenhues |
Subject: |
shell function spy update |
Date: |
Thu, 3 Feb 2005 08:30:55 +0100 |
User-agent: |
Mutt/1.5.6+20040907i |
IMHO Autoconf should restrict its functions to the as_*/ac_* namespace.
Even if the tested functions live strictly in a subshell, it is probably
better to do so anyway. The patch below does that. Furthermore, it
adds a check whether the shell restores positional parameters. Without
that feature, shell functions have very limited value for possible use
in Autoconf, IMVHO. This is what I gather from Libtool experience (we
haven't found anyone using such a shell, though).
Only lightly tested, sorry.
Regards,
Ralf
* lib/m4sugar/m4sh.m4 (_AS_SHELL_FN_WORK): Move func_* to
as_func_*. Add test to check whether positional parameters
are restored after function return.
Index: lib/m4sugar/m4sh.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sh.m4,v
retrieving revision 1.132
diff -u -r1.132 m4sh.m4
--- lib/m4sugar/m4sh.m4 28 Jan 2005 21:21:32 -0000 1.132
+++ lib/m4sugar/m4sh.m4 1 Feb 2005 21:22:42 -0000
@@ -266,35 +266,38 @@
# This is a spy to detect "in the wild" shells that do not support shell
# functions correctly. It is based on the m4sh.at Autotest testcases.
m4_define([_AS_SHELL_FN_WORK],
-[func_return () {
+[as_func_return () {
(exit [$]1)
}
-func_success () {
- func_return 0
+as_func_success () {
+ as_func_return 0
}
-func_failure () {
- func_return 1
+as_func_failure () {
+ as_func_return 1
}
-func_ret_success () {
+as_func_ret_success () {
return 0
}
-func_ret_failure () {
+as_func_ret_failure () {
return 1
}
exitcode=0
-AS_IF([func_success], [],
+AS_IF([as_func_success], [],
[exitcode=1
- echo func_failure succeeded.])
-AS_IF([func_failure],
+ echo as_func_failure succeeded.])
+AS_IF([as_func_failure],
[exitcode=1
- echo func_success failed.])
-AS_IF([func_ret_success], [],
+ echo as_func_success failed.])
+AS_IF([as_func_ret_success], [],
[exitcode=1
- echo func_ret_success failed.])
-AS_IF([func_ret_failure],
+ echo as_func_ret_success failed.])
+AS_IF([as_func_ret_failure],
[exitcode=1
- echo func_ret_failure succeeded.])
+ echo as_func_ret_failure succeeded.])
+AS_IF([( set x; as_func_ret_success y && test x = "[$]1" )], [],
+ [exitcode=1
+ echo positional parameters were not saved.])
test $exitcode = 0])
- shell function spy update,
Ralf Wildenhues <=