[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFH] zsh shell function portability issue
From: |
Ralf Wildenhues |
Subject: |
Re: [RFH] zsh shell function portability issue |
Date: |
Mon, 13 Oct 2008 23:06:45 +0200 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
* Paolo Bonzini wrote on Mon, Oct 13, 2008 at 11:59:22AM CEST:
> You will remember the shell function portability issue in zsh...
Yes; sigh.
> Do you think that these functions:
reindented to:
ac_func_c_try_compile()
{
rm -f conftest.$ac_objext
if
{
(ac_try="$ac_compile"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_compile") 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status);
} &&
{
test -z "$ac_c_werror_flag" ||
test ! -s conftest.err
} && test -s conftest.$ac_objext; then
ac_retval=0
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=1
fi
rm -f core conftest.err conftest.$ac_objext
return $ac_retval
}
>
>
> and
ac_func_c_try_run()
{
if
{ (ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status);
} &&
{ ac_try='./conftest$ac_exeext'
{
(case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\""
$as_echo "$ac_try_echo") >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status);
};
};
then
ac_retval=0
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext
conftest.$ac_objext conftest$ac_exeext
return $ac_retval
}
> are portable? (Yeah, the code is totally unreadable).
Pretty likely not:
$ zsh --version
zsh 4.2.3 (powerpc-apple-darwin8.0)
$ zsh
$ f () { ( exit 1); echo $?; }; f
0
$ f () { ( exit 1) && echo bad; }; f
bad
$ f () { { ( exit 1); } && echo bad; }; f
bad
> IMO the first should be okay because it only uses (exit ...) to drive an
> && construct. In the second instead, I am worried about this:
>
> (eval "$ac_try") 2>&5
> ac_status=$?
>
> but do we need that eval at all? Maybe it can be replaced with a {...}
> instead?
I'm pretty sure that application code relies on that eval, even if
lib/autoconf/*.m4 doesn't. I don't think this can be changed without
much friction.
Cheers,
Ralf