set -e causes AS_IF to exit in else clause

Peter Johansson <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.bugs
Message-ID <[email protected]>
Hi,

This is with autoconf 2.71.

I use autom4te to create a script and discovered that the script exits 
when the else clause in AS_IF is reached. It seems it's caused by the 
combination that function as_fn_nop() is called in the else clause and 
that I have 'set -e' earlier in the script.

I suppose my workaround will be that I remove the 'set -e', but the 
behaviour is quite unexpected. I've boiled down the script to a minimal 
test case that illustrates the behaviour


cat > foo.m4sh <<EOF
AS_INIT
AS_ME_PREPARE
set -e

if test x"$1" = x"apple"; then
   echo apple;
else
   echo not apple;
fi

AS_IF([test x"$1" = x"orange"],
       [AS_ECHO([orange])],
       [AS_ECHO([not orange])])
EOF

autom4te -l M4sh -o foo.sh foo.m4sh

sh -x foo.sh hello world

...

+ set -e
+ test x = xapple
+ echo not apple
not apple
+ test x = xorange
+ as_fn_nop
+ return 1

i.e., it exits before printing anything about the orange

Thanks,

Peter
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.