-
Notifications
You must be signed in to change notification settings - Fork 3
/
NEWS
290 lines (235 loc) · 12.2 KB
/
NEWS
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
NEWS: User visible changes in the ed line editor.
* Register extensions
Add register extensions to `m' and `t' commands. Deleted lines are
copied to a default register. The syntax of the register extensions
is as follows.
(.,.)m|t>[>][k] where optional k = 0, 1, ..., 9. Moves or copies,
respectively, the addressed lines to register k (or default
anonymous register, if k is not given). If `>>' lines are appended
to end of register. Otherwise, any previous register contents are
overwritten.
<[k]m|t(.) where optional k = 0, 1, ..., 9. Moves or copies,
respectively, contents of register k (or default anonymous
register, if k is not given) to after the addressed line.
<[k]m|t>[>][j] where optional k = 0, 1, ..., 9 and j = 0, 1, ...,
9. Moves or copies, respectively, contents of register k (or
default anonymous register, if k is not given) to register j (or
default anonymous register, if j is not given). If `>>' lines are
appended to end of register. Otherwise, any previous register
contents are overwritten.* Localization of error messages.
* Extended regex command-line switches (`-r' or `--regexp-extended')
* Updated paging.
A page backward command `Z' has been added. The full syntax is:
(.)Zn, where n is an optional window size.
Commands for scrolling one half-page forward `]' and backward `['
have been added. They display the addressed line in the middle of
the page. A subsequent command scrolls one-half page
forward/backward. They also accept and optional window size
argument.
* Ex(1) style `!' filtering
Enabled via the configure option --enable-external-filter. Syntax is
`(addr1,addr2)! shell-command'. Text from addr1 through addr2 is
modified in the same manner as the following sequence of commands:
addr1,addr2 w ! shell-command >o.tmp 2>&1
addr2 r o.tmp
addr1,addr2 d
* File globbing
Enabled via the configure option `--enable-file-glob'. If multiple
file arguments are given on the command line, they define a
`default file list'. The first file in the list is opened for
editing. The remaining files are accessed via the following
commands, which extend traditional ed syntax.
extended ed command description
------------------- -----------
en or En Edits next file in `default file list' and
sets `default file name'. Any lines in the
editor buffer are deleted before the new
file is read. Attempting to go past end of
list raises an error. The new `default
file name' and size are printed to stdout.
ep or Ep Edits previous file in `default file list'
and sets `default file name'. Any lines
in the editor buffer are deleted before
the new file is read. Attempting to go
past beginning of list raises an error.
The new `default file name' and size are
printed to stdout.
~e or ~E Edits first file in `default file list' and
sets `default file name' -- i.e., the `~e'
command with no arguments effectively
rewinds the `default file list'. NB: To re-
read the current file from disk, use the `e'
command with no arguments instead. Any lines
in the editor buffer are deleted before
the new file is read. The new `default
file name' and size are printed to stdout.
~e PATTERN or Edits first file in list generated by
~E PATTERN glob (PATTERN) relative to the current
directory. Sets the `default file list'
and `default file name' accordingly. The
new `default file name' and size are
printed to stdout.
If no files match `pattern', then
`pattern' is used instead. If pattern
begins with exclamation mark (!), it is
interpreted as a shell command and affects
neither the `default file name' nor
default `default file list' -- i.e., it is
equivalent to the command:
e !shell command
(q.v.).
Since the `~e' command accepts multiple
arguments separated by whitespace,
whitespace within an argument must be
backslash (\) escaped -- e.g.:
~e file\ one file\ two
~f Prints `default file list' to stdout. The
`default file name' is unchanged.
~f PATTERN Sets `default file list' generated by
glob (PATTERN) and sets `default file
name' to first file in list. Prints (new)
`default file list' to stdout. If no files
match `PATTERN', then `PATTERN' is used
instead.
($)~r Reads first file in `default file list' to
after the addressed line. The `default
file name' is unchanged.
($)~r PATTERN Reads first file in list generated by
glob (PATTERN) to after the addressed
line. Sets the `default file list' and
`default file name' iff they were
previously unset.
If no files match `PATTERN', then
`PATTERN' is used instead. If PATTERN
begins with exclamation mark (!), it is
interpreted as a shell command and affects
neither the `default file name' nor
default `default file list' -- i.e., it is
equivalent to the command:
r !shell command
(q.v.).
wn or Wn Equivalent to a `w' (or `W') command fol-
lowed by an `en' command. The name and
size of the file written to are printed to
stdout.
wp or Wp Equivalent to a `w' (or `W') command fol-
lowed by an `ep' command. The name and
size of the file written to are printed to
stdout.
~w or ~W Equivalent to a `w' (or `W') command fol-
lowed by an `~e' command. The name and
size of the file written to are printed to
stdout.
~w PATTERN or Equivalent to a `w' (or `W') command fol-
~W PATTERN lowed by an `~e PATTERN' command. The name
and size of the file written to are
printed to stdout.
If no files match `PATTERN', then
`PATTERN' is used instead. If PATTERN
begins with exclamation mark (!), it is
interpreted as a shell command and affects
neither the `default file name' nor
default `default file list' -- i.e., it is
equivalent to the command:
w !shell command
(q.v.).
* Ed scripts (#! /bin/ed -f)
`-f' and `--file' options accept a command script argument. To
invoke ed directly on a script, the first (shebang) line should be
the magic text: `#! /path/to/ed -f'.
* Verbose command-line switch (-v, --verbose)
`-V' and `--verbose' options enable errors diagnostics.
These are equivalent to ed's `H' command, which toggles verbose mode
on and off. To enable error diagnostics by default, (one of) these
may be added to the `ED' environment variable.
* Emacs-parsable error messages
Ed scripts can be debugged in Emacs' `shell-script' mode by setting
the first line of the script (shebang line) to:
#! /path/to/ed -vf
The `-v' option enables diagnostics and the `-f' option causes ed to
interpret the rest of the file as a script. If the script is named,
say, script.ed, then it may be `compiled' via the sequence of Emacs
commands:
C-x C-w ; When prompted, type: script.ed
M-x shell-command (or M-S-!) ; When prompted, type: chmod +x script.ed
M-x compile ; When prompted, type: ./script.ed file-to-process
C-x ` ; Jumps to next script error.
* Embedded newline characters (`\n') in shell escapes.
A newline can be embedded in a shell escape by entering a backslash
at the end of a line. No other backslash escape processing is done.
In general, the shell sees all but the last trailing backslash:
$ ed -p \*
*!echo hello \
world
hello
sh: line 2: world: command not found
!
*!echo hello \\
world
hello world
!
*!echo hello \\\
world
hello \
sh: line 2: world: command not found
!
*!echo hello \\\\
world
hello \world
!
*
* Support `ED' environment variable
Enabled via the configure option `--enable-ed-envar'. Allows default
command-line options (e.g., command prompt) to be set via the `ED'
environment variable. Options should be separated by whitespace, as
they are on the command line.
* File locking
Enabled via configure option `--enable-file-lock'. If file locking
is enabled, then:
1) Reading from a file with an advisory lock prints a warning
diagnostic in verbose mode if stdin is a tty.
2) Writing to a file with an advisory lock succeeds, barring other
issues, by ignoring any file locking errors.
* Don't exit on errors if standard input is from a pipe.
Per historical precedent.
* Reset exit status upon a successful write
For non-scripted, interactive sessions only. This goes against the
SUSv3 standard.
* Autotest testsuite framework.
To add a new test, create a script in testsuite/ with suffix .t or
.err, depending on whether it should succeed or fail. Update
testsuite/Makefile.am, run `./bootstrap.sh' and then `make check'.
For scripts that are expected to succeed, they read data from a file
with same base name and suffix .d. Another file with .r suffix
should contain the expected result. The test is run via a command
sequence like:
{ cat test.t; echo "w test.o"; } >test.script
ed -s test.d <test.script
cmp test.o test.r && echo okay || echo failed
Scripts that are expected to fail use the script itself as a data
file and are interpreted in two ways: as a file and as a pipe. A
piped script does not exit on errors and should therefore generate
output. This is compared against a file with .rr suffix:
{ cat test.err; echo "w test.ro"; } >test.script
ed -s test.err <test.script && echo failed
cat test.script | ed -s test.err
cmp test.ro test.rr && echo okay || echo failed
* SUSv3 line addressing
For example, the address `,5' is expanded to the address range as
`1,5' and `;' is expanded to `.,$'.
* Interrupts fixed on Linux.
* Global NUL substitution
Per historical precedent, given a line of text `abc', the
substitution `s/a*/x/g' yields `xbxcx'. A rationale is attempted in
the ChangeLog.
* Add short options `-h' (--help) and `-V' (--version)
* Remove `--quiet' and `--silent' long options.
The long option `--script' is equivalent to `-' or `-s'.
* Properly initialize PATH_MAX on BSD systems.
* Preserve command prompt.
Command prompt could be corrupted by GNU getopts, interrupt signals
and toggling (i.e., `P' command).
* Honor SUSv3 environment variables COLUMNS, LINES and TMPDIR.
SUSv3 only requires that ed recognize TMPDIR.
* Fix buffer overflow and temp file vulnerabilities.
* Substitution sets the current address to the last modified line.