1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
GNU ed is an 8-bit clean, more or less POSIX-compliant implementation of
the standard Unix line editor. These days, full-screen editors have
rendered `ed' mostly of historical interest. Nonetheless, it appeals to
a handful of aging programmers who still believe that "Small is Beautiful".
Extensions to and deviations from the POSIX standard are described below.
See the file INSTALL for compilation and installation instructions.
Try "ed --help" for usage instructions.
Report bugs to <bug-ed@gnu.org>.
Ed home page: http://www.gnu.org/software/ed/ed.html
For a description of the ed algorithm, see Kernighan and Plauger's book
"Software Tools in Pascal," Addison-Wesley, 1981.
GNU ed(1) is not strictly POSIX compliant, as described in the
POSIX 1003.1-2004 document. The following is a summary of omissions
and extensions to, and deviations from, the POSIX standard.
OMISSIONS
---------
* Locale(3) is not supported.
EXTENSIONS
----------
* Though GNU ed is not a stream editor, it can be used to edit binary files.
To assist in binary editing, when a file containing at least one ASCII
NUL character is written, a newline is not appended if it did not
already contain one upon reading. In particular, reading /dev/null
prior to writing prevents appending a newline to a binary file.
For example, to create a file with GNU ed containing a single NUL character:
$ ed file
a
^@
.
r /dev/null
wq
Similarly, to remove a newline from the end of binary `file':
$ ed file
r /dev/null
wq
* BSD commands have been implemented wherever they do not conflict with
the POSIX standard. The BSD-ism's included are:
* `s' (i.e., s[n][rgp]*) to repeat a previous substitution,
* `W' for appending text to an existing file,
* `wq' for exiting after a write, and
* `z' for scrolling through the buffer.
* The POSIX interactive global commands `G' and `V' are extended to
support multiple commands, including `a', `i' and `c'. The command
format is the same as for the global commands `g' and `v', i.e., one
command per line with each line, except for the last, ending in a
backslash (\).
* The file commands `E', `e', `r', `W' and `w' process a <file>
argument for backslash escapes; i.e., any character preceded by a
backslash is interpreted literally. If the first unescaped character
of a <file> argument is a bang (!), then the rest of the line is
interpreted as a shell command, and no escape processing is performed
by GNU ed.
* For SunOS ed(1) compatibility, GNU ed runs in restricted mode if invoked
as red. This limits editing of files in the local directory only and
prohibits shell commands.
DEVIATIONS
----------
* For backwards compatibility, the POSIX rule that says a range of
addresses cannot be used where only a single address is expected has
been relaxed.
* To support the BSD `s' command (see EXTENSIONS above),
substitution patterns cannot be delimited by numbers or the characters
`r', `g' and `p'. In contrast, POSIX specifies any character expect
space or newline can used as a delimiter.
* Since the behavior of `u' (undo) within a `g' (global) command list is
not specified by POSIX, GNU ed follows the behavior of the SunOS ed:
undo forces a global command list to be executed only once, rather than
for each line matching a global pattern. In addtion, each instance of
`u' within a global command undoes all previous commands (including
undo's) in the command list. This seems the best way, since the
alternatives are either too complicated to implement or too confusing
to use.
* The `m' (move) command within a `g' command list also follows the SunOS
ed implementation: any moved lines are removed from the global command's
`active' list.
* If GNU ed is invoked with a name argument prefixed by a bang (!), then
the remainder of the argument is interpreted as a shell command. To invoke
ed on a file whose name starts with bang, prefix the name with a
(quoted) backslash.
* For backwards compatibility, errors in piped scripts do not force ed
to exit. POSIX only specifies ed's response for input via regular
files (including here documents) or tty's.
TESTSUITE
---------
The files in the `testsuite' directory with suffixes `.t', `.d', `.r',
`.pr' and `.err' are used for testing ed. To run the tests, configure
the package and type `make check' from the build directory. The tests do
not exhaustively verify POSIX compliance nor do they verify correct
8-bit or long line support.
The test file suffixes have the following meanings:
.t Template - a list of ed commands from which an ed script is
constructed
.d Data - read by an ed script
.r Result - the expected output after processing data via an ed
script.
.pr Result from a piped ed script.
.err Error - invalid ed commands that should generate an error
The output of the tests is written to the files errs.ck, pipes.ck and
scripts.ck. At the end of the tests, these files are grep'ed for error
messages, which look like:
*** The script u.ed exited abnormally ***
or:
*** Output u.o of script u.ed is incorrect ***
The POSIX requirement that an address range not be used where at most
a single address is expected has been relaxed in this version of ed.
Therefore, the following script templates are disabled:
=-err.t.posix
a1-err.posix
i1-err.posix
k1-err.posix
r1-err.posix
To use these, remove the .posix suffix and run the tests as described
above.
Copyright (C) 2006, 2007, 2008, 2009 Antonio Diaz Diaz.
This file is free documentation: you have unlimited permission to copy,
distribute and modify it.
The file Makefile.in is a data file used by configure to produce the
Makefile. It has the same copyright owner and permissions that this
file.
|