POSIX revision 1.7 1 1.7 alm This version of ed(1) is not strictly POSIX compliant, as described in
2 1.7 alm the POSIX 1003.2 document. The following is a summary of the omissions,
3 1.7 alm extensions and possible deviations from POSIX 1003.2.
4 1.7 alm
5 1.7 alm OMISSIONS
6 1.7 alm ---------
7 1.7 alm 1) Locale(3) is not supported yet.
8 1.7 alm
9 1.7 alm 2) For backwards compatibility, the POSIX rule that says a range of
10 1.7 alm addresses cannot be used where only a single address is expected has
11 1.7 alm been relaxed.
12 1.7 alm
13 1.7 alm EXTENSIONS
14 1.7 alm ----------
15 1.7 alm 1) BSD commands have been implemented wherever they do not conflict with
16 1.7 alm the POSIX standard. The BSD-ism's included are:
17 1.7 alm i) `s' (i.e., s[rgp]*) to repeat a previous substitution,
18 1.7 alm ii) `W' for appending text to an existing file,
19 1.7 alm iii) `wq' for exiting after a write,
20 1.7 alm iv) `z' for scrolling through the buffer, and
21 1.7 alm v) BSD line addressing syntax (i.e., `^' and `%') is recognized.
22 1.7 alm
23 1.7 alm 2) If crypt(3) is available, files can be read and written using DES
24 1.7 alm encryption. The `x' command prompts the user to enter a key used for
25 1.7 alm encrypting/ decrypting subsequent reads and writes. If only a newline
26 1.7 alm is entered as the key, then encryption is disabled. Otherwise, a key
27 1.7 alm is read in the same manner as a password entry. The key remains in
28 1.7 alm effect until encryption is disabled. For more information on the
29 1.7 alm encryption algorithm, see the bdes(1) man page. Encryption/decryption
30 1.7 alm should be fully compatible with SunOS DES.
31 1.7 alm
32 1.7 alm 3) The POSIX interactive global commands `G' and `V' are extended to
33 1.7 alm support multiple commands, including `a', `i' and `c'. The command
34 1.7 alm format is the same as for the global commands `g' and `v', i.e., one
35 1.7 alm command per line with each line, except for the last, ending in a
36 1.7 alm backslash (\).
37 1.7 alm
38 1.7 alm 4) Though ed is not a binary editor, it can be used (if painfully) to edit
39 1.7 alm binary files. To assist in binary editing, when a file containing at
40 1.7 alm least one ASCII NUL character is written, a newline is not appended if
41 1.7 alm it did not already contain one upon reading. For instance, to create
42 1.7 alm a file containing a single NUL, one might use:
43 1.7 alm $ cp /dev/null file
44 1.7 alm $ ed file
45 1.7 alm a
46 1.7 alm ^@
47 1.7 alm .
48 1.7 alm wq
49 1.7 alm $
50 1.7 alm
51 1.7 alm 5) An extension to the POSIX file commands `E', `e', `r', `W' and `w' is
52 1.7 alm that <file> arguments are processed for backslash escapes, i.e., any
53 1.7 alm character preceded by a backslash is interpreted literally. If the
54 1.7 alm first unescaped character of a <file> argument is a bang (!), then the
55 1.7 alm rest of the line is interpreted as a shell command, and no escape
56 1.7 alm processing is performed by ed.
57 1.7 alm
58 1.7 alm 6) The ex(1) editor's ! (bang) command syntax is supported, i.e.:
59 1.7 alm i) commands of the form:
60 1.7 alm (addr1,addr2) !shell-command
61 1.7 alm replace the addressed lines with the output of the shell-
62 1.7 alm command, and
63 1.7 alm ii) commands of the form:
64 1.7 alm [rwe] !!
65 1.7 alm read, write, or edit, respectively, the previous shell-command.
66 1.7 alm
67 1.7 alm 7) For SunOS ed(1) compatibility, ed runs in restricted mode if invoked
68 1.7 alm as red. This limits editing of files in the local directory only and
69 1.7 alm prohibits shell commands.
70 1.7 alm
71 1.7 alm DEVIATIONS
72 1.7 alm ----------
73 1.7 alm 1) Since the behavior of `u' (undo) within a `g' (global) command list is
74 1.7 alm not specified by POSIX, it follows the behavior of the SunOS ed (this
75 1.7 alm is the best way, I think, in that the alternatives are either too
76 1.7 alm complicated to implement or too confusing to use): undo forces a global
77 1.7 alm command list to be executed only once, rather than for each line
78 1.7 alm matching a global pattern. In addtion, each instance of `u' within a
79 1.7 alm global command undoes all previous commands (including undo's) in the
80 1.7 alm command list.
81 1.7 alm
82 1.7 alm 2) The `m' (move) command within a `g' command list also follows the SunOS
83 1.7 alm ed implementation: any moved lines are removed from the global command's
84 1.7 alm `active' list.
85 1.7 alm
86 1.7 alm 3) If ed is invoked with a name argument prefixed by a bang, then the
87 1.7 alm remainder of the argument is interpreted as a shell command. To invoke
88 1.7 alm ed on a file whose name starts with bang, prefix the name with a
89 1.7 alm backslash.
90