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 #87
Topic: ar Relevant Clauses: 6.1

POSIX.2 clause 6.1 specifies the semantics of the "ar" utility. My question regards the behavior of "ar" when invoked with the syntax ar -r archive_name where archive_name names a file that does not currently exist. The Synopsis subclause (6.1.1) lists five valid syntaxes for invoking "ar". One of these is ar -r [-cuv] archive file ... The file argument is not shown as optional. Since the syntax shown in three other cases does show the file argument as optional, it is reasonable to assume that this is intentional, and that invoking "ar" with the -r option without a file argument is always an error. Subclause 6.1.3 describes the options to "ar". In the description of the -r option, the standard states (in part) Replace or add file(s) to archive. If the archive named by archive does not exist, a new archive shall be created and a diagnostic message shall be written to standard error (unless the -c option is specified). If no file(s) are specified and the archive exists, the results are undefined.

One can read this description as implying that, if an archive is named that does not exist, it is permissible to omit the file argument and that in this case a new, empty archive is created. This contradicts the earlier interpretation. Which is correct? In other words, when "ar" is invoked as decribed, what must a conforming implementation do?

Proposed Interpretation Response (from mjc)
A conforming implementation may allow the use of the -r option without file operands. The behaviour of ar in this case is undefined. Applications should always specify one or more file operands with the -r option.

Rationale for Interpretation
The only behaviour that the quoted passage specifies when the file operand are missing is if the archive exists, and that behaviour is undefined. It does not specify any behaviour if the file arguments are missing and the archive does not exist. While one could read it to mean that the file operands are optional, it does not state that, so the synopsis must hold. Even if it is read to mean the file operands are optional, the only behaviour that may be assumed is that it is undefined. There is nothing that suggests that an empty archive will be created, and it is not clear that an application or user would want to create an empty archive. Historical practice is to require file operands when the -r option is used, and nothing in the rationale suggests that the committee intended to change that.

Interpretation Response
The standard does not specify the meaning of ar -r archive-name. None of the synopsis forms given for ar specify -r option with only one operand. The standard does not speak to this issue, and as such no conformance distinction can be made between alternative implementations based on this. This is being referred to the sponsor.

Rationale for Interpretation