/bin/sh -e function parsing strangeness
Vasil Dimov
vd at datamax.bg
Sun Jun 26 08:27:16 GMT 2005
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Can anyone explain this:
% sh -ec 'f() { return 5 ; } ; if f ; then echo tt ; else echo ff ; fi'
ff
% sh -ec 'f() { return 5 ; : ; } ; if f ; then echo tt ; else echo ff ; fi'
% echo $?
5
If any commands appear after the return statement in a function,
then -e flag triggers untested command failure although function call is
tested with `if' statement.
-----BEGIN PGP SIGNATURE-----
iD8DBQFCvmbWFw6SP/bBpCARAo2GAJ9DT0FeeUEbweidCklxj8V8uEeXHQCgmNd7
pT2zbB8UF9TClhRUWpyZyf4=
=Alpo
-----END PGP SIGNATURE-----
More information about the freebsd-hackers
mailing list