/bin/sh compatibility issue
Steve O'Hara-Smith
steve at sohara.org
Wed May 10 09:59:46 PDT 2006
On Wed, 10 May 2006 17:49:38 +0200
joerg at xxxxxxxxxxxxxxxxx wrote:
> On Wed, May 10, 2006 at 03:39:53PM +0000, Johannes Hofmann wrote:
> > The following shell script outputs "false1" with all shells I tried
> > but with /bin/sh on DragonFly. Is this a known incompatibility?
>
> I have to read the POSIX definitions, but this doesn't look very wrong
> at least. Actually, I can understand this behaviour at the very least.
It doesn't seem to be consistent with the description of -e
in the sh manpage.
-e errexit
Exit immediately if any untested command fails in non-interactive mode.
The exit status of a command is considered to be explicitly tested if the
command is used to control an if, elif, while, or until; or if the command
is the left hand operand of an ``&&'' or ``||'' operator.
I've quoted the script with added comments.
#!/bin/sh
set -e
if true; then
false && echo "huh?" # This shouldn't exit because false is LHS of &&
fi
echo "false1"
false # This should exit because false is not explicitly tested
echo "false2"
--
C:>WIN | Directable Mirror Arrays
The computer obeys and wins. | A better way to focus the sun
You lose and Bill collects. | licences available see
| http://www.sohara.org/
More information about the Users
mailing list