.
Last update: 1997-05-20
9945-2-104 _____________________________________________________________________________ Topic: expr | operator Relevant Sections: 4.22.7 Defect Report: ----------------------- Date: Tue, 4 Apr 1995 17:39:13 -0700 From: [email protected] (Chuck Hickey [CONTRACTOR]) Dear Standards Board, I would like to request a formal interpretation on the following issue concerning the expr utility in POSIX.2. Standard: ISO/IEC 9945-2:1993 Topic: expr | operator Relevant Sections: 4.22.7 In ISO/IEC 9945-2:1993 section 4.22.7 (Extended Description of the expr utility), P277, L4159-4160, the description of the | and & operators is: expr1 | expr2 Returns the evaluation of expr1 if it is neither null nor zero; otherwise, it returns the evaluation of expr2. expr1 & expr2 Returns the evaluation of expr1 if neither expression evaluates to null or zero; otherwise, returns zero. This requires that the command: expr "" \| "" produce an empty line as its output. In both BSD and System V historic practice, the | operator acted as a boolean arithmetic operator like the & operator. If the expressions evaluated to null strings, the result was "0\n", not a null. The rationale in section E.4.22, P904, L6209-6213 acknowledges that expr could be replaced by other shell constructs in the POSIX.2 shell, but says the utility was kept because of the many historical shell scripts that use it. The rationale also mentions that other changes in early drafts of the standard were backed out because they weren't historic practice (see L6229-6230). It seems strange that this change to historical practice was not documented if it was intentional. To match historic BSD and System V implementations, the description of the | operator on P277, L4159-4169 should have been something like: expr1 | expr2 Returns the evaluation of expr1 if it is neither null nor zero; otherwise, the evaluation of expr2 if it is not null; otherwise, returns zero. Was this change to historic practice intentional? Interpretation response ------------------------ The standard states the behavior for the | operator for the expr cmd, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor. Rationale: None Forwarded to Interpretations group: Apr 5 1995 Proposed resolution circulated: May 16th Comments due: June 15th Finalised: June 16th 1995