Re: /bin/sh -e function parsing strangeness
From: Vasil Dimov (vd_at_datamax.bg)
Date: 06/26/05
- Previous message: Vasil Dimov: "/bin/sh -e function parsing strangeness"
- In reply to: Vasil Dimov: "/bin/sh -e function parsing strangeness"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 26 Jun 2005 12:00:25 +0300 To: hackers@freebsd.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sun, Jun 26, 2005 at 11:27:02AM +0300, Vasil Dimov wrote:
>
> 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.
>
I see, -e counts for each command inside function body, no matter that
the whole function return status is tested with `if'.
% sh -ec 'f() { ls /nonexistent ; ls / ; } ; if f ; then echo tt ; else echo ff ; fi'
ls: /nonexistent: No such file or directory
%
Probably this should be considered as a sh "feature".
-----BEGIN PGP SIGNATURE-----
iD8DBQFCvm6pFw6SP/bBpCARAu6FAKCCoGXwounURHk6o4m8huqEDtmX9wCfXqxf
M0BT7Ej0fG9Iulgr/A18MMk=
=/5jF
-----END PGP SIGNATURE-----
_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
- Previous message: Vasil Dimov: "/bin/sh -e function parsing strangeness"
- In reply to: Vasil Dimov: "/bin/sh -e function parsing strangeness"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|