WG15 Defect Report Ref: 9945-2-141
Topic: ed commands

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


Last update: 1997-05-20



	Topic:                  ed  commands
	Relevant Sections:

Defect Report:
	From: bryan@mks.com (Bryan West)
	Date: Wed, 4 Oct 1995 11:33:28 -0400

Dear Sir,

I request an interpretation of ISO/IEC 9945-2:1993, section ed: Extended Description: ed Commands.

Section, page 263, lines 3666-3676 give general rules for
dealing with multiple commands on a line.  In particular, it
states that

	[A]ny command ... can be suffixed by the letter l, n, or
	p; in which case ... the command shall be executed and
	then the new current line shall be written as described
	below for the l, n, and p commands. ...  Also, the g, G,
	v, and V commands shall take a command as a parameter.

Section, page 266 describes the behaviour of the 'G'
command: interactive global command.

Section, page 270 describes the behaviour of the 'V'
command: interactive global not-matched command.

What is the behaviour of the G and V commands when supplied flags
l, n, or p?  For example :


The description from section would imply that the prompt
produced by the 'G' and 'V' commands is unaffected by the
suffixed format commands, but that the new current line displayed
at the end of the command execute is so affected.  However,
historically, ed demonstrates the following behaviour:

		ed -p '*'
		The wiz-o-matic
		kitchen utensil
		will slice, dice,
		and make Julian fries.
		kitchen utensil			<- G prompt line
		.=				<- user command
		2	kitchen utensil$	<- flag applied
		2				<- user command output
		and make Julian fries.		<- next G prompt line
		.=				<- next user command
		4				<- user command output

Note in this example that the n and l flags appear to be disabled
for second and subsequent interactive commands (unless the
interactive command explicitly specified flags of its own).  This
behaviour seems, to us, to be a bug in the historical ed.

Should a standard conforming ed behave as we described above,
namely printing only the new current line according to the format
specifiers given, or should it apply the format specifiers to the
'G' and 'V' prompt lines as well, which would satisfy the intent
of the (buggy) historical behaviour?  That is, should ed behave

	a) The flags print the new current line after all
	   matches have been processed:

		kitchen utensil
		and make Julian fries.
		4	and make Julian fries.$ <- new current line printed
						   by the flags as the last
						   action of the G command
						   before returning to the *

or as:
	b) Each displayed prompt line by G/V (to which the current
	   line is set) is displayed according to the flags:

		2       kitchen utensil$        <- prompt written according to
		kitXhen utensil			<- output of s command
		4	and make Julian fries.$ <- prompt written according
						   to flags
		and make Zulian fries.          <- output of s command

This latter behaviour would seem to hew more closely to the
behaviour of the historical ed, and is also more useful to the
user running the 'G' command.

Thank you for your attention to this matter.

Bryan West

Interpretation response

The standard clearly states the requirements for the behavior of ed
and conforming implementations must conform to this. 

The standard states that the flags given on the uppercase global commands
causes the new current line after the command has been completed to
be written as specified by the flags.


Note: (not part of the interpretation)
In the example ed -p '*' , i (insert)  won't work as it is not valid 
at address zero.

Forwarded to Interpretations group: Oct 6 1995
Recirculated for 30 day review: Oct 19 1995
Finalised: Nov 20 1995