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