NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/38736 (/bin/sh: several problems with 'set -e')

> Synopsis: /bin/sh: several problems with 'set -e'

> State-Changed-From-To: open->closed
> State-Changed-By:
> State-Changed-When: Mon, 26 May 2008 14:58:25 +0000
> State-Changed-Why:
> At least one of your examples ("! true") is explicitly listed as an
> exception of the "set -e" behaviour in the POSIX spec:

No. You read this spec incorrectly. Reread it.

Subsentence that describes `!' case:

  "-e When this option is on, if a simple command fails for any of the
  reasons listed in Consequences of Shell Errors or returns an exit
  status value >0, and is not a pipeline preceded by the ! reserved
  word, then the shell shall immediately exit.

"simple command" here means 'true' WITHOUT leading '!' (see below).
Therefore, this sentence is about '! false' which should not exit from
shell script.  This is obviously because the exit status of whole
command if TRUE.
   "A "simple command" is a sequence of optional variable assignments
   and redirections, in any sequence, optionally followed by words and
   redirections, terminated by a control operator."

Another definitions:

   "2.9.2 Pipelines
   A pipeline is a sequence of one or more commands
   separated by the control operator '|'." (ONE OR MORE!)

   "A command is one of the following: Simple command (see Simple
   Commands) Pipeline (see Pipelines) List compound-list (see Lists)
   Compound command (see Compound Commands) Function definition (see
   Function Definition Command)"

> Please compose a new list of test cases and compare them *carefully*
> with the spec and submit a new PR.
Do not close bugs if they are not fixed.

Best regards, Aleksey Cheusov.

Home | Main Index | Thread Index | Old Index