POSIX revision 1.7
11.7SalmThis version of ed(1) is not strictly POSIX compliant, as described in
21.7Salmthe POSIX 1003.2 document.  The following is a summary of the omissions,
31.7Salmextensions and possible deviations from POSIX 1003.2.
41.7Salm
51.7SalmOMISSIONS
61.7Salm---------
71.7Salm1) Locale(3) is not supported yet.
81.7Salm
91.7Salm2) For backwards compatibility, the POSIX rule that says a range of
101.7Salm   addresses cannot be used where only a single address is expected has
111.7Salm   been relaxed.
121.7Salm
131.7SalmEXTENSIONS
141.7Salm----------
151.7Salm1) BSD commands have been implemented wherever they do not conflict with
161.7Salm   the POSIX standard.  The BSD-ism's included are:
171.7Salm	i) `s' (i.e., s[rgp]*) to repeat a previous substitution,
181.7Salm	ii) `W' for appending text to an existing file,
191.7Salm	iii) `wq' for exiting after a write,
201.7Salm	iv) `z' for scrolling through the buffer, and
211.7Salm	v) BSD line addressing syntax (i.e., `^' and `%')  is recognized.
221.7Salm
231.7Salm2) If crypt(3) is available, files can be read and written using DES
241.7Salm   encryption.  The `x' command prompts the user to enter a key used for
251.7Salm   encrypting/ decrypting subsequent reads and writes.  If only a newline
261.7Salm   is entered as the key, then encryption is disabled.  Otherwise, a key
271.7Salm   is read in the same manner as a password entry.  The key remains in
281.7Salm   effect until encryption is disabled.  For more information on the
291.7Salm   encryption algorithm, see the bdes(1) man page.  Encryption/decryption
301.7Salm   should be fully compatible with SunOS DES.
311.7Salm
321.7Salm3) The POSIX interactive global commands `G' and `V' are extended to 
331.7Salm   support multiple commands, including `a', `i' and `c'.  The command
341.7Salm   format is the same as for the global commands `g' and `v', i.e., one
351.7Salm   command per line with each line, except for the last, ending in a
361.7Salm   backslash (\).
371.7Salm
381.7Salm4) Though ed is not a binary editor, it can be used (if painfully) to edit
391.7Salm   binary files.  To assist in binary editing, when a file containing at
401.7Salm   least one ASCII NUL character is written, a newline is not appended if
411.7Salm   it did not already contain one upon reading.  For instance, to create
421.7Salm   a file containing a single NUL, one might use:
431.7Salm   $ cp /dev/null file
441.7Salm   $ ed file
451.7Salm   a
461.7Salm   ^@
471.7Salm   .
481.7Salm   wq
491.7Salm   $
501.7Salm
511.7Salm5) An extension to the POSIX file commands `E', `e', `r', `W' and `w' is
521.7Salm   that <file> arguments are processed for backslash escapes, i.e.,  any
531.7Salm   character preceded by a backslash is interpreted literally.  If the
541.7Salm   first unescaped character of a <file> argument is a bang (!), then the
551.7Salm   rest of the line is interpreted as a shell command, and no escape
561.7Salm   processing is performed by ed.
571.7Salm
581.7Salm6) The ex(1) editor's ! (bang) command syntax is supported, i.e.:
591.7Salm	i) commands of the form:
601.7Salm		(addr1,addr2) !shell-command
611.7Salm	   replace the addressed lines with the output of the shell-
621.7Salm	   command, and
631.7Salm	ii) commands of the form:
641.7Salm		[rwe] !!
651.7Salm	    read, write, or edit, respectively, the previous shell-command.
661.7Salm
671.7Salm7) For SunOS ed(1) compatibility, ed runs in restricted mode if invoked
681.7Salm   as red.  This limits editing of files in the local directory only and
691.7Salm   prohibits shell commands.
701.7Salm
711.7SalmDEVIATIONS
721.7Salm----------
731.7Salm1) Since the behavior of `u' (undo) within a `g' (global) command list is
741.7Salm   not specified by POSIX, it follows the behavior of the SunOS ed (this
751.7Salm   is the best way, I think, in that the alternatives are either too
761.7Salm   complicated to implement or too confusing to use):  undo forces a global
771.7Salm   command list to be executed only once, rather than for each line
781.7Salm   matching a global pattern.  In addtion, each instance of `u' within a
791.7Salm   global command undoes all previous commands (including undo's) in the
801.7Salm   command list.
811.7Salm
821.7Salm2) The `m' (move) command within a `g' command list also follows the SunOS
831.7Salm   ed implementation: any moved lines are removed from the global command's
841.7Salm   `active' list.
851.7Salm
861.7Salm3) If ed is invoked with a name argument prefixed by a bang, then the
871.7Salm   remainder of the argument is interpreted as a shell command.  To invoke
881.7Salm   ed on a file whose name starts with bang, prefix the name with a
891.7Salm   backslash.
90