WG15 Defect Report Ref: 9945-2-81
Topic: sed


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

.

Last update: 1997-05-20


								9945-2-81

 _____________________________________________________________________________

	Topic:			sed
	Relevant Sections:	4.55


Defect Report:
-----------------------
Date: Fri, 7 Oct 1994 15:26:29 -0700
From: Fred Zlotnick <fred@mindcraft.com>


I would like to request an official, binding interpretation from the
WG15 concerning the following point in ISO/IEC 9945-2:1993 (POSIX.2).

POSIX.2 Subclause 4.55 specifies the semantics of the "sed" utility.
In subclause 4.55.7.3 the semantics of various subcommands are
specified.  My question has to do with the "a" and "r" subcommands.
The description of the "a" subcommand states that the command

	[1addr]a\
	<text>

shall cause sed to

	Write <text> to standard output just before each attempt to
	fetch a line of input, whether by executing the N command or by
	beginning a new cycle.

Similarly, the description of the "r" subcommand states that the command

	[1addr]r <file>

shall cause sed to

	Copy the contents of <file> to standard output just before each
	attempt to fetch a line of input.

My question has to do with the behavior of these commands on the first
input line when the address is omitted.  In such a case, POSIX.2 states
(subclause 4.55.7.1) that

	A command with no addresses shall select every pattern space.

If sed is executed with a script that includes an "a" command or an "r"
command with no addresses, is the action of "a" or "r" taken prior to
input of the first line in the input stream?  My reading of the above
sections of the standard is that this action should be taken prior to
fetching each line, including the first one.  However, it appears that
existing practice is for the action of "a" or "r" to occur on each
fetch attempt after the first, but not on the first.  Does this
behavior conform to the requirements of POSIX.2?


Thank you for your attention to this matter.

Interpretation response:
-------------------------


The standard states the behavior for input and addressing for sed, 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: 09 Oct 94

Proposed resolution sent for review: 19th Nov 94
Resolved: 10th Dec 94