Answering questions that may arise related to the meaning of portions of an IEEE standard concerning specific applications.

IEEE Standards Interpretations for IEEE Std 1003.2™-1992 IEEE Standard for Information Technology--Portable Operating System Interfaces (POSIX®)--Part 2: Shell and Utilities

Copyright © 1996 by the Institute of Electrical and Electronics Engineers, Inc. 3 Park Avenue New York, New York 10016-5997 USA All Rights Reserved.

Interpretations are issued to explain and clarify the intent of a standard and do not constitute an alteration to the original standard. In addition, interpretations are not intended to supply consulting information. Permission is hereby granted to download and print one copy of this document. Individuals seeking permission to reproduce and/or distribute this document in its entirety or portions of this document must contact the IEEE Standards Department for the appropriate license. Use of the information contained in this document is at your own risk.

IEEE Standards Department, Copyrights and Permissions, 445 Hoes Lane, Piscataway, New Jersey 08855-1331, USA

Interpretation Request #79
Topic: sh -o Relevant Clauses: 4.56

In the description of the "sh"utility in POSIX.2 subclause 4.56, the option to -o is shown as required. The semantics of the -o option are specified by reference to subclause 3.14.11 (the "set"builtin command), in which no description of the behavior is given when the option to -o is omitted. POSIX.2 subclause 2.11.3 states in part Unless otherwise stated in the utility description, when ...a required option argument is not provided, standard utilities shall issue a diagnostic message to standard error and exit with nonzero exit status. My question regards the use of the -o option to "sh"with no option argument. If the command sh -o < script_file is issued, is the shell required to issue a diagnostic and exit with nonzero status? Or is the shell, as an extension, permitted to have other behavior? If the latter, is this true for other utilities with required option arguments as well? There are two ways to look at this: The behavior is unspecified, and implementations are free to provide any desired behavior as an extension. The behavior is governed by the language cited above from 2.11.3. As a point of practice, historical implementations have allowed the use of "set -o"and "sh -o"with the semantics of displaying the current settings of all options.

Interpretation Response
The specification in 2.11.3 clearly states the behaviour for sh -o and conforming implementations must conform to this.

Rationale for Interpretation