[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-ed] Problems in POSIX description of ed reported
From: |
Andrew Moore |
Subject: |
[Bug-ed] Problems in POSIX description of ed reported |
Date: |
Fri, 04 Aug 2017 00:29:27 -0400 |
Antonio Diaz writes:
| Sorry for taking so long. I have finally reported the problems with the 'c'
and 'i' commands here:
| http://austingroupbugs.net/view.php?id=1130
Your rationale for rejecting 0c is based on implementation details.
Per BSD ed man page, which includes GNU ed 0.2:
One exception to the rule that addresses represent line numbers is the
address 0 (zero). This means "before the first line", and is legal wher-
ever it makes sense.
This is a general rule. In the particular case of the command `c’, address 0
never makes
sense, except as a synonym for 1. By analogy, think of military time, where
24:00 is the same as 00:00 (i.e., midnight).
Let’s provide some cases:
CASE 1. Empty file: 0c not allowed because there’s nothing to change
$ ed <<EOF
H
0c
EOF
?
script, line 2: Address out of range
$
CASE 2. Non-empty file: 0c is equivalent to 1c
$ ed <<EOF
H
a
1
.
0c
hello
.
,p
Q
EOF
hello
$
CASE 3. Non-empty file: 0,2c is equivalent to 1,2c because 0c is equivalent to
1c
$ ed <<EOF
H
a
1
2
3
.
0,2c
hello
.
,p
Q
EOF
hello
3
$
| http://austingroupbugs.net/view.php?id=1131
In the case of 0i, the description could be better, but the intent is clear
enough.
In the particular case of an empty buffer, 0i adds text starting with address 1.
So in that sense “0i is the same as 1i”.
-AM
- [Bug-ed] Problems in POSIX description of ed reported,
Andrew Moore <=