WG15 Defect Report Ref: 9945-2-105
Topic: expr standard output representing a null string


This is an approved interpretation of 9945-2:1993.

.

Last update: 1997-05-20


								9945-2-105

 _____________________________________________________________________________

	Topic:                  expr standard output representing a null string
	Relevant Sections:      4.22.6.1

Defect Report:
-----------------------

	Date: Tue, 4 Apr 1995 17:37:40 -0700
	From: Chuck.Hickey@Eng.Sun.COM (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.


	In ISO/IEC 9945-2:1993 section 4.22.6.1 (Standard Output of
	the expr utility), P276, L4127-4129, the description of the
	standard output representing expressions evaluating to zero and
	to null strings is:
		The character '0' shall be written to indicate a zero
		value and nothing shall be written to indicate a null
		string.

	This could be interpreted literally to mean that the output in
	these two cases must not include a newline character.  (At
	least one developer of a POSIX.2 test suite has used this
	interpretation for the null string, but not for '0'.)

	In both BSD and System V historic practice, an expression
	evaluating to zero produced "0\n" on standard output and an
	expression evaluating to a null string produced an empty line
	on standard output.

	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
	second sentence of the Standard Output section on P276,
	L4128-2129 should have been something like:
		An empty line shall be written to indicate a
		null string.
	Note that the zero case is already handled in the first sentence
	in that section.

	Was this change to historic practice intentional?




Interpretation response
------------------------
The standard is clear that a nl is not appended to the results of the 
evaluation in any case.  This is not historical behavior, however,
conforming implementations must conform to this.  However, concerns
have been raised about this which are being referred to the sponsor.

 

Rationale:
None
Proposed resolution circulated: May 16th
Comments due: June 15th
Finalised: June 16th 1995