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 #86
Topic: backreferences Relevant Clauses: 126.96.36.199
In the description of backreferences in POSIX.2 subclause 188.8.131.52, the standard states (in part): The backreference expression \n shall match the same (possibly empty) string of characters as was matched by a subexpression enclosed between ( and ) preceding the n. The character n shall be a digit from 1 through 9, specifying the n'th subexpression... My question revolves around the use of the word " shall" in the last sentence. Is this a restriction on applications, or on implementations? In the former case, an expression with a backreference such as \0 would be nonportable, having unspecified behavior. In the latter case, it would have to be treated as invalid by any conforming implementation.
" The character n shall be a digit from 1 through 9, ..." is a requirement for a standard conforming application. The standard does not require that an implementation return an error if another value such as 0 is used. The standard clearly states behavior for backreference expressions and conforming implementations must conform to this.
Rationale for Interpretation