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
0000962 [1003.1(2013)/Issue7+TC1] Shell and Utilities Comment Clarification Requested 2015-06-20 20:42 2019-06-10 08:54
Reporter rhymoid View Status public  
Assigned To
Priority normal Resolution Accepted As Marked  
Status Closed  
Name Stijn van Drongelen
Organization
User Reference
Section sort
Page Number 3211
Line Number 107616-107618
Interp Status Approved
Final Accepted Text see Note: 0002764
Summary 0000962: Should utilities continue when reading one of multiple files fails?
Description Consider the following sequence of commands:

    set +e

    rm -f aaaa
    echo something >xxxx
    echo c_mpletely >yyyy
    echo different >zzzz

    cat aaaa xxxx 2>/dev/null
    sed -e s/_/o/ aaaa yyyy 2>/dev/null
    sort aaaa zzzz 2>/dev/null

On FreeBSD and Mac OS X, this sequence prints the following to standard output

    something
    completely

To be specific: cat and sed continue their task when a specified file could not be opened, while sort terminates without output to stdout when any of the specified files could not be opened.

From the description of cat in the POSIX specification, it seems that it is not defined whether the cat, sed, and sort utilities should terminate when an error occurred when processing a specified file. It would seem that the output of the sequence above may range from "" to "something\ncompletely\ndifferent\n" across POSIX implementations.
Desired Action Clarify the constraints, if any, on the behaviour of cat, sed, and sort when opening or reading one of their input files fails.
Tags tc2-2008
Attached Files

- Relationships

-  Notes
(0002727)
geoffclare (manager)
2015-06-22 08:41

See XCU 1.4 Utility Description Defaults, under CONSEQUENCES OF ERRORS, where it says:

    The following shall apply to each utility, unless otherwise stated:

    * If the requested action cannot be performed on an operand
      representing a file, directory, user, process, and so on, the
      utility shall issue a diagnostic message to standard error and
      continue processing the next operand in sequence, but the final
      exit status shall be returned as non-zero.


It appears that most, if not all, implementations of sort do not follow this general rule. We should add something to the sort page (either in OPERANDS or CONSEQUENCES OF ERRORS) to say that if sort encounters an error when opening or reading a file operand, it may exit without processing later operands.
(0002764)
rhansen (manager)
2015-07-16 16:15

Interpretation response
------------------------
The standard states that sort must carry on processing later operands after an error is encountered with an earlier operand, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor.

Rationale:
-------------
Existing implementations of sort stop processing immediately after encountering an error when reading input files.

Notes to the Editor (not part of this interpretation):
-------------------------------------------------------
On page 3211 line 107618 (sort OPERANDS), append the following to the description of the file operand:
If sort encounters an error when opening or reading a file operand, it may exit without writing any output to standard output or processing later operands.

On page 3213 line 107687 (sort CONSEQUENCES OF ERRORS), change from:
Default.
to:
The default requirements shall apply, except that if sort encounters an error when opening or reading a file operand, it may exit without writing any output to standard output or processing later operands.
(0002769)
ajosey (manager)
2015-07-17 07:59

Interpretation Proposed: 17 July 2015
(0002816)
ajosey (manager)
2015-09-07 11:32

Interpretation approved: 7 Sep 2015

- Issue History
Date Modified Username Field Change
2015-06-20 20:42 rhymoid New Issue
2015-06-20 20:42 rhymoid Name => Stijn van Drongelen
2015-06-20 20:42 rhymoid Section => cat, sed, sort
2015-06-20 20:42 rhymoid Page Number => N/A
2015-06-20 20:42 rhymoid Line Number => N/A
2015-06-22 08:41 geoffclare Note Added: 0002727
2015-07-16 15:53 rhansen Section cat, sed, sort => sort
2015-07-16 15:53 rhansen Page Number N/A => 3211
2015-07-16 15:53 rhansen Line Number N/A => 107616-107618
2015-07-16 15:53 rhansen Interp Status => ---
2015-07-16 16:15 rhansen Note Added: 0002764
2015-07-16 16:16 rhansen Interp Status --- => Pending
2015-07-16 16:16 rhansen Final Accepted Text => see Note: 0002764
2015-07-16 16:16 rhansen Status New => Interpretation Required
2015-07-16 16:16 rhansen Resolution Open => Accepted As Marked
2015-07-16 16:16 rhansen Tag Attached: tc2-2008
2015-07-17 07:59 ajosey Interp Status Pending => Proposed
2015-07-17 07:59 ajosey Note Added: 0002769
2015-09-07 11:32 ajosey Interp Status Proposed => Approved
2015-09-07 11:32 ajosey Note Added: 0002816
2019-06-10 08:54 agadmin Status Interpretation Required => Closed


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