Date: Mon, 14 Sep 2009 10:40:05 GMT From: "Alexander Melkov" <melkov@comptek.ru> To: freebsd-bugs@FreeBSD.org Subject: Re: bin/111343: sh(1) and bash(1) with -e sometimes fail to testerrors in functions Message-ID: <200909141040.n8EAe5AD041911@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/111343; it has been noted by GNATS.
From: "Alexander Melkov" <melkov@comptek.ru>
To: "Jilles Tjoelker" <jilles@stack.nl>,
<bug-followup@FreeBSD.org>
Cc:
Subject: Re: bin/111343: sh(1) and bash(1) with -e sometimes fail to testerrors in functions
Date: Mon, 14 Sep 2009 14:18:06 +0400
> Replacing the function call with the function definition, the behaviour
> seems reasonable.
Ok, thanks. The problem is much worse then.
==> test1.sh <==
set -e
{ false; echo ok; } || echo failed
if ! { false; echo ok; } ; then
echo failed
fi
if ! ( false; echo ok; ) ; then
echo failed
fi
- outputs
ok
ok
ok
> The command is tested, so -e should not trigger.
Why testing the command should change the operation *within* that command?
That's well beyond traditional programming, thus obviously a bug.
> In general, set -e is not a good idea for more complicated scripts
> because its rules can be confusing and inconsistent across shells. You
> can achieve a similar effect by putting '|| exit' after commands.
Ok, very nice. I'll just take my 10000 lines of scripts and add 10000 times
'|| exit'.
Actually -e is well defined and operates reliably except the case mentioned
in this PR.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200909141040.n8EAe5AD041911>
