POSIX revision 16
116SalmThis version of ed is not strictly POSIX compliant, as described in the 216SalmPOSIX 1003.2 Draft 11.2 document. BSD commands have been implemented 316Salmwherever they do not conflict with the POSIX standard. For backwards 416Salmcompatibility, the POSIX rule that says a range of addresses cannot be 516Salmused where only a single address is expected has been relaxed. 616Salm 716SalmThe BSD commands included are: 816Salm 1) `s' (i.e., s[rgp]*) to repeat a previous substitution, 916Salm 2) `W' for appending text to an existing file, 1016Salm 3) `wq' for exiting after a write, and 1116Salm 4) `z' for scrolling through the buffer. 1216SalmBSD line addressing syntax (i.e., `^' and `%'). is also recognized. 1316Salm 1416SalmThe POSIX interactive global commands `G' and `V' are extended to support 1516Salmmultiple commands, including `a', `i' and `c'. The command format is the 1616Salmsame as for the global commands `g' and `v', i.e., one command per line 1716Salmwith each line, except for the last, ending in a backslash (\). 1816Salm 1916SalmIf crypt is available, files can be read and written using DES encryption. 2016SalmThe `x' command prompts the user to enter a key used for encrypting/ 2116Salmdecrypting subsequent reads and writes. If only a newline is entered as 2216Salmthe key, then encryption is disabled. Otherwise, a key is read in the 2316Salmsame manner as a password entry. The key remains in effect until 2416Salmencryption is disabled. For more information on the encryption algorithm, 2516Salmsee the bdes(1) man page. Encryption/decryption should be fully compatible 2616Salmwith SunOS DES. 2716Salm 2816SalmAn extension to the POSIX file commands `E', `e', `r', `W' and `w' is that 2916Salm<file> arguments are processed for backslash escapes, i.e., any character 3016Salmpreceded by a backslash is interpreted literally. If the first unescaped 3116Salmcharacter of a <file> argument is a bang (!), then the rest of the line 3216Salmis interpreted as a shell command, and no escape processing is performed 3316Salmby ed. 3416Salm 3516SalmThe vi editor's bang command syntax is supported, i.e., 3616Salm(addr1,addr2) !<shell-cmd> replaces the addressed lines with the output of 3716Salm the command <shell-cmd>. 3816Salm[rwe] !! reads/writes/edits the previous !<shell-cmd>. 3916Salm 4016SalmIf ed is invoked with a name argument prefixed by a bang, then the 4116Salmremainder of the argument is interpreted as a shell command. To invoke 4216Salmed on a file whose name starts with bang, prefix the name with a backslash. 4316Salm 4416Salmed runs in restricted mode if invoked as red. This limits editing of 4516Salmfiles in the local directory only and prohibits !<shell-cmd> commands. 4616Salm 4716SalmThough ed is not a binary editor, it can be used (if painfully) to edit 4816Salmbinary files. To assist in binary editing, when a file containing at 4916Salmleast one ASCII NUL character is written, a newline is not appended 5016Salmif it did not already contain one upon reading. 51