bug-ed
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-ed] Problems in POSIX description of ed reported


From: Antonio Diaz Diaz
Subject: Re: [Bug-ed] Problems in POSIX description of ed reported
Date: Thu, 07 Sep 2017 00:40:40 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.9.1.19) Gecko/20110420 SeaMonkey/2.0.14

Hi Andrew,

Sorry for the late answer. I was on vacation. :-)

Andrew L. Moore wrote:
Your rationale for rejecting 0c is based on implementation details.
No, it is not.

Antonio, to quote your rationale:

     ... accepting 0 as a valid address for the c command does not
     make sense because the c command executes a d   command ...

The c command operates on existing lines; it replaces them with some other thing. Removing the lines is its job. Executing a d command is not an implementation detail. It is part of the c command description:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ed.html
"The c command shall delete the addressed lines, then accept input text that replaces these lines".

IMO, commands operating on existing lines should not accept an invalid address, neither 0 nor $+1.


Now let me take the naive user's perspective: Since the command
`0a' means "insert before the first line" then it seems reasonable to
expect the command `0i' to also "insert before the first line".  And
to be consistent with modal commands `a' and `i', address `0'
should be valid against command `c' as well.

This is where the naive user's reasoning fails. The c command uses input mode to collect the text that will replace the deleted lines, but this does not make it similar to a or i with respect to line addressing. The c command operates on existing lines, while the a and i commands just insert text at some place, which may be "before the first line", "between two lines", or "after the last line".


The naive user's argument leaves something to be desired, but I
believe the POSIX rationale is that, when possible, give the user the
benefit of the doubt.

I think it is important for a program to behave correctly. If quirks are allowed, the naive user will require the same quirks to be ported to all implementations.


POSIX singles out command `c' because it's one of the three modal
commands - along with `a' and `i'.

I do not consider c, a and i to be in the same category. The fact that the three use input mode has nothing to do with the addresses that are valid for each of them.


For what it's worth, I don't believe that `0c' was valid in Ken
Thompson's ed, but I don't have access to an old UNIX(tm) system at
the moment to confirm that. If so, you could use that in your
argument. But striving to do something reasonable before throwing an
error is part of the Unix philosophy, as outlined, e.g., in "The UNIX
Programming Environment" by Kernighan and Pike.

Well, I do not think that accepting 0c is something reasonable. IMO 0a should be used instead.


Best regards,
Antonio.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]