Interpretations

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 #151
Topic: pr Relevant Clauses: 4.49.3

This request deals with the semantics of the "-i" option to the "pr" utility. These semantics are specified in POSIX.2 subclause 4.49.3 lines 8037-8043, which state (in part): -i[char][gap] In output, replace multiple s with s wherever two or more adjacent s reach column positions gap + 1, 2 x gap + 1, 3 x gap + 1, etc. If gap is zero or is omitted, default settings at every eighth column position shall be assumed. The issue that I would like addressed is the following: If an input line contains a space at position (n x gap + 1) followed by n consecutive spaces, should the output file contain a single space at position (n x gap + 1) followed by a single tab, or should it contain two tabs? An example may make this clearer. Suppose that "inputfile" contains the following two lines 1234567890 This line shows column positions 123 90 (five consecutive spaces, no tabs, in the second line) and suppose that the command pr -i4 inputfile is issued. Should the output generated by the second line be 123 ^I90 or 123^I^I90 >Here ^I stands for a tab. I contend that the second output is correct (or that, at best, the standard is ambiguous). To support this, note that the five consecutive spaces reach column position 9 = (2 x 4 + 1), and therefore (according to the specification) should all be replaced by tabs. The fact that the first of these spaces is at a tab position does not seem relevant and is not addressed in the standard.

Interpretation Response
The standard is clear. The five s should be replaced by two s. However, while reviewing this interpretation request, we note that historical implementations would replace one or more s with the appropriate number of s. This issue has been forwarded to the sponsors.

Rationale for Interpretation
None.