Austin Group Defect Tracker

Aardvark Mark IV

Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000052 [1003.1(2008)/Issue 7] Shell and Utilities Objection Error 2009-06-25 13:19 2013-04-16 13:06
Reporter geoffclare View Status public  
Assigned To ajosey
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Geoff Clare
Organization The Open Group
User Reference
Section 2.14
Page Number 2358
Line Number 74545
Interp Status Approved
Final Accepted Text Note: 0000227
Summary 0000052: description of set -e does not match existing practice
Description  The description of set -e does not match existing practice in
 several respects, as discussed at length on the austin-group-l
 mailing list in threads beginning 2009-02-10 ("error handling in
 shell pipelines") and 2009-02-17 ("set -e description").

 The new description of set -e proposed below is taken from the
 minutes of the March 12th teleconference, with a few minor changes:

 * shallification
 * changed "!" to "the ! reserved word"
 * changed "2.8.1" to "[xref to 2.8.1]"
 * changed "AND or OR list" to "AND-OR list"

 and the two major changes, related to pipelines and functions,
 discussed in replies to the minutes.

 I have also added the fix to 2.9.2 identified during the original
 discussion, and some application usage and rationale.
Desired Action Replace the description of -e with:

  -e When this option is on, when any command fails (for any of the
      reasons listed in [xref to 2.8.1] or by returning an exit status
      greater than zero) the shell immediately shall exit with the
      following exceptions:

      1) The failure of any individual command in a multi-command
          pipeline shall not cause the shell to exit. Only the
          failure of the pipeline itself shall be considered.

      2) The -e setting shall be ignored when executing the compound
          list following the while, until, if, or elif reserved word,
          a pipeline beginning with the ! reserved word, or any
          command of an AND-OR list other than the last.

      3) If the exit status of a compound command other than a
          subshell command was the result of a failure while -e was
          being ignored, then -e shall not apply to this command.

      This requirement applies to the shell environment and each
      subshell environment separately. For example, in

          set -e; (false; echo one) | cat; echo two

      the false command causes the subshell to exit without executing
      echo one; however, echo two is executed because the exit status
      of the pipeline (false; echo one) | cat is zero.

In the APPLICATION USAGE for the set builtin utility at
page 2360 line 74631, change "None" to:

    Application writers should avoid relying on set -e within
    functions. For example, in the following script:

        set -e
        start() {
           echo some_server started successfully
        start || echo >&2 some_server failed

    the -e setting is ignored within the function body (because the
    function is a command in an AND-OR list other than the last).
    Therefore if some_server fails, the function carries on to
    echo "server started successfully", and the exit status of the
    function is zero (which means "server failed" is not output).

In the RATIONALE for the set builtin utility after
page 2361 line 74660, add a new paragraph:

    The description of the -e option is intended to match the
    behavior of the 1988 version of the KornShell.

At page 2319 line 73188 section 2.9.2, change:

    If the reserved word ! does not precede the pipeline, the


    If the pipeline does not begin with the ! reserved word, the
Tags tc1-2008
Attached Files

- Relationships
related to 0000537Closedajosey 1003.1(2008)/Issue 7 for set -e, compound commands and functions case should be clarified 
related to 0000715Appliedajosey Online Pubs Typo in description of "set -e" 

-  Notes
Don Cragun (manager)
2009-06-25 13:21
edited on: 2009-06-26 06:27

Originally reported by gwc:xxxxxxxxxxxxx
Wed, 18 Mar 2009 09:24:16 +0000
with Subject: Defect in XCU 2.14 set

Transcribed by Don Cragun from xcubug3.txt ERN 8

Submitter tag "gwc set -e"

Don Cragun (manager)
2009-06-25 13:30

Despite the Description saying the Action text is based on the minutes
of the March 12th (2009) teleconference, the original Action text was
overwritten in xcubug3.txt with the final action before being
transcribed into Aardvark Mark III. Thus, the Accepted As Marked
resolution is correct even though the final text is shown in the Desired
Action field instead of in a Note.
ajosey (manager)
2009-09-17 15:08
edited on: 2009-09-17 15:10

Interpretation response
The standard states the requirements for set -e
and conforming implementations must conform to this. However, concerns
have been raised about this which are being referred to the sponsor."


Notes to the Editor (not part of this interpretation):

Make the change suggested by the submitter

melkov (reporter)
2012-01-20 06:33
edited on: 2012-01-20 07:31

Regarding to function execution logic described here, I would like to ask respectable reviewers to discard this change in favor of 0000537 because:

1. This behavior only reflects a bug in original ksh implementation;
2. Unfamiliar programmers do not expect this behavior because it is against general logic;
3. It is hard to imagine a shell code that relies on this bug;
4. It is possible to give existing shell interpreters as much time to change the behavior as necessary. Correct logic can be off by default with corresponding -o option to turn it on.

- Issue History
Date Modified Username Field Change
2009-06-25 13:19 Don Cragun New Issue
2009-06-25 13:19 Don Cragun Status New => Under Review
2009-06-25 13:19 Don Cragun Assigned To => ajosey
2009-06-25 13:19 Don Cragun Name => Geoff Clare
2009-06-25 13:19 Don Cragun Organization => The Open Group
2009-06-25 13:19 Don Cragun Section => 2.14
2009-06-25 13:19 Don Cragun Page Number => 2358
2009-06-25 13:19 Don Cragun Line Number => 74545
2009-06-25 13:21 Don Cragun Note Added: 0000091
2009-06-25 13:30 Don Cragun Note Added: 0000092
2009-06-25 13:30 Don Cragun Reporter Don Cragun => geoffclare
2009-06-25 13:30 Don Cragun Status Under Review => Interpretation Required
2009-06-25 13:30 Don Cragun Resolution Open => Accepted As Marked
2009-06-25 16:38 Don Cragun Tag Attached: real bug in aardvark
2009-06-26 06:27 Don Cragun Note Edited: 0000091
2009-07-30 16:09 msbrown Tag Detached: real bug in aardvark
2009-08-11 16:23 Don Cragun Interp Status => Pending
2009-09-17 15:08 ajosey Note Added: 0000227
2009-09-17 15:10 ajosey Note Edited: 0000227
2009-09-17 15:15 ajosey Final Accepted Text => Note: 0000227
2009-09-17 15:41 nick Interp Status Pending => Proposed
2009-10-09 16:04 ajosey Interp Status Proposed => Approved
2010-09-20 09:05 geoffclare Tag Attached: tc1-2008
2012-01-19 09:39 geoffclare Relationship added related to 0000537
2012-01-20 06:33 melkov Note Added: 0001099
2012-01-20 07:31 melkov Note Edited: 0001099
2013-04-16 13:06 ajosey Status Interpretation Required => Closed
2013-06-20 21:35 weeks Relationship added related to 0000715

Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker