bug-ed
[Top][All Lists]
Advanced

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

Re: [Bug-ed] GNU ed 1.14-pre1 released


From: Antonio Diaz Diaz
Subject: Re: [Bug-ed] GNU ed 1.14-pre1 released
Date: Mon, 25 Apr 2016 21:09:18 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv:1.8.1.4) Gecko/20070601 SeaMonkey/1.1.2

Ori Avtalion wrote:
Quoting POSIX's RATIONALE section:

  "For consistency with the a and r commands and better user functionality,
   the i and c commands must also accept an address of 0,
   in which case 0i is treated as 1i and likewise for the c command."

This has some problems. Given an empty buffer after starting ed, you'd
want "i" to work (that is, "0i").

If the quote is correct. "i" ("0i") is interpreted as "1i" which gives
an error on an empty buffer, since line 1 doesn't exist yet.

It seems that the description of ed in the POSIX standard has in fact several problems. In addition to 0i not working on an empty buffer if interpreted literally, I found the following:

First, it makes sense for 0a and 0r to set the current address to 0 if no text is appended/read; it allows a following .a or .r command to append text exactly after the first text, even if the first text was empty. The following sequence

  0r file
  .a
  foo
  .

will append 'foo' after the text read from file.

Therefore, if it is true that "This command [i] differs from the a command only in the placement of the input text", it makes sense for 0i to set the current address to 0.

Second, POSIX states that address 0 shall be valid for the a, c and i commands, but accepting 0 as a valid address for the c command does not make sense because the c command executes a d command, which does not admit an address of 0.

The command
  1,2c
is (almost) equivalent to
  1,2d
  .i

With respect to addresses, the c command should be treated as the d command, not as a, i or r; commands a, i and r do not delete anything.

I propose the following solutions:

Make the c command to no longer accept 0 as an address. (ed-0.2 didn't accept it).

Write to the POSIX committee requesting:
- a clarification of the meaning of 0i; address 0 should always mean 'before the first line (if any)' instead of sometimes being considered as a synonym for address 1.

- the elimination of the requirement that the c command must accept address 0.


Best regards,
Antonio.



reply via email to

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