Date: Sun, 26 Jun 2005 11:27:02 +0300 From: Vasil Dimov <vd@datamax.bg> To: hackers@freebsd.org Subject: /bin/sh -e function parsing strangeness Message-ID: <20050626082702.GA76984@sinanica.bg.datamax>
index | next in thread | raw e-mail
-----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-----
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050626082702.GA76984>
