NAME
ed — edit
text
SYNOPSIS
ed [−p string] [−s] [file] Obsolescent Version: ed [−p string] [−] [file]
DESCRIPTION
The ed utility is a line-oriented text
editor that shall use two modes: command mode and input mode. In command
mode the input characters shall be interpreted as commands, and in input
mode they shall be interpreted as text. See
EXTENDED DESCRIPTION .
OPTIONS
The ed utility shall conform to the
utility argument syntax guidelines described in 2.10.2, except for its
nonstandard usage of − in the obsolescent version. The following
options shall be supported by the implementation:
OPERANDS
The following operand shall be supported by the implementation:
- file
-
If the file argument is given,
edshall simulate an e command on the file named by the pathname, file, before accepting commands from the standard input.
STANDARD INPUT
The standard input shall be a text file consisting of commands, as described in EXTENDED DESCRIPTION .
INPUT FILES
The input files shall be text files.
ENVIRONMENT VARIABLES
The following environment variables shall affect the execution of
ed:
HOME-
This variable shall determine the pathname of the user’s home directory.
LANG-
This variable shall determine the locale to use for the locale categories when both LC_ALL and the corresponding environment variable (beginning with LC_ ) do not specify a locale. See 2.6.
LC_ALL-
This variable shall determine the locale to be used to override any values for locale categories specified by the settings of LANG or any environment variables beginning with LC_.
LC_COLLATE-
This variable shall determine the locale for the behavior of ranges, equivalence classes, and multicharacter collating elements within regular expressions.
LC_CTYPE-
This variable shall determine the locale for the interpretation of sequences of bytes of text data as characters (e.g., single- versus multibyte characters in arguments and input files), the behavior of character classes within regular expressions.
LC_MESSAGES-
This variable shall determine the language in which messages should be written.
ASYNCHRONOUS EVENTS
The ed utility shall take the standard
action for all signals (see 2.11.5.4), with the following exceptions:
SIGINT The ed utility shall
interrupt its current activity, write the string "?\n" to standard
output, and return to command mode (see
EXTENDED DESCRIPTION ).
SIGHUP
If the buffer is not empty and has changed since the last write, the
ed utility shall attempt to write a copy of the
buffer in a file. First, the file named ed. hup in
the current directory shall be used; if that fails, the file named
ed. hup in the directory named by the
HOME environment variable shall be used. In any case, the
ed utility shall exit without returning to command
mode.
STANDARD OUTPUT
Various editing commands and the prompting feature (see −p) write to standard output, as described in EXTENDED DESCRIPTION .
STANDARD ERROR
Used only for diagnostic messages.
OUTPUT FILES
The output files shall be text files whose formats are dependent on the editing commands given.
EXTENDED DESCRIPTION
The ed utility shall operate on a copy of
the file it is editing; changes made to the copy shall have no effect on the
file until a w (write) command is given. The copy of the text is called the
buffer in this clause, although no attempt is made to imply a specific
implementation. Commands to ed have a simple and
regular structure: zero, one, or two addresses followed by a
single-character command, possibly followed by parameters to that command.
These addresses specify one or more lines in the buffer. Every command that
requires addresses has default addresses, so that the addresses very often
can be omitted. If the −p option is specified, the prompt string
shall be written to standard output before each command is read. In general,
only one command can appear on a line. Certain commands allow text to be
input. This text is placed in the appropriate place in the buffer. While
ed is accepting text, it is said to be in input
mode. In this mode, no commands shall be recognized; all input is merely
collected. Input mode is terminated by entering a line consisting of two
characters: a period (.) followed by a <newline>. This line is not
considered part of the input text.
ED REGULAR EXPRESSIONS
The ed utility shall support basic regular
expressions, as described in 2.8.3. Since regular expressions in
ed are always matched against single lines, never
against any larger section of text, there is no way for a regular expression
to match a <newline>. A null RE shall be equivalent to the last RE
encountered. Regular expressions are used in addresses to specify lines, and
in some commands (for example, the s substitute command) to specify portions
of a line to be substituted.
ED ADDRESSES
Addressing in ed relates to the current
line. Generally, the current line is the last line affected by a command.
The current line number is the address (line number) of the current line.
The exact effect on the current line number is discussed under the
description of each command. The f, h, H, k, P, w, =, and ! commands shall
not modify the current line number. Addresses are constructed as
follows:
- The character . (period) shall address the current line.
- The character $ shall address the last line of the buffer.
- A positive decimal number n shall address the n-th line of the buffer. The first line in the buffer is line number 1.
- ’x shall address the line marked with the mark name character x, which shall be a lowercase letter from the portable character set. Lines can be marked with the k command described in MARK COMMAND .
- An RE enclosed by slashes (/) shall address the first line found by searching forward from the line following the current line toward the end of the buffer and stopping at the first line containing a string matching the RE. [As stated in ED REGULAR EXPRESSIONS , an address consisting of a null RE delimited by slashes (//) shall address the next line containing the last RE encountered.] If necessary, the search shall wrap around to the beginning of the buffer and continue up to and including the current line, so that the entire buffer is searched. Within the RE, the sequence \/ shall represent a literal slash instead of the RE delimiter.
- An RE enclosed in question-marks (?) shall address the first line found by searching backward from the line preceding the current line toward the beginning of the buffer and stopping at the first line containing a string matching the RE. If necessary, the search wraps around to the end of the buffer and continues up to and including the current line. Within the RE, the sequence \? shall represent a literal question-mark instead of the RE delimiter.
- An address followed by a plus sign (+) or a minus sign (-) followed by a decimal number specifies that address plus (respectively minus) the indicated number of lines. The plus sign can be omitted.
- If an address begins with + or -, the addition or subtraction is taken with respect to the current line number; for example, −5 is understood to mean .−5.
- If an address ends with + or -, then 1 shall be added to or subtracted from the address, respectively. As a consequence of this rule and of rule
- immediately above, the address − shall refer to the line preceding the current line. Moreover, trailing + and − characters shall have a cumulative effect, so −− shall refer to the current line number less 2.
- A comma (,) shall stand for the address pair 1,$, while a semicolon (;) shall stand for the pair .,$.
Commands require zero, one, or two addresses. Commands that require no addresses shall regard the presence of an address as an error. Commands that accept one or two addresses assume default addresses when no addresses are given, as described in ED COMMANDS . If one address is given to a command that allows two addresses, the command shall operate as if it were specified as: given_address;. command If more addresses are given than such a command requires, the results are undefined. Typically, addresses are separated from each other by a comma. They can also be separated by a semicolon. In the latter case, the current line number (.) shall be set to the first address, and only then shall the second address be calculated. This feature can be used to determine the starting line for forward and backward searches [see rules (5) and (6) above]. The second address of any two-address sequence shall correspond to a line that does not precede, in the buffer, the line corresponding to the first address.
ED COMMANDS
In the following list of ed commands, the
default addresses are shown in parentheses. The number of addresses shown in
the default shall be the number expected by the command. The parentheses are
not part of the address; they show that the given addresses are the default.
It is generally invalid for more than one command to appear on a line.
However, any command (except e, E, f, q, Q, r, w, and !) can be suffixed by
the letter l, n, or p; in which case, except for the l, n, and p commands,
the command shall be executed and then the new current line shall be written
as described below under the l, n, and p commands. When an l, n, or p suffix
is used with an l, n, or p command, the command shall write to standard
output as described below, but it is unspecified whether the suffix writes
the current line again in the requested format or whether the suffix has no
effect. For example, the pl command (base p command with an l suffix) shall
either write just the current line or shall write it twice—once as
specified for p and once as specified for l. Also, the g, G, v, and V
commands shall take a command as a parameter. Each address component can be
preceded by zero or more <blank>s. The command letter can be preceded
by zero or more <blank>s. If a suffix letter (l, n, or p) is given, it
shall immediately follow the command. The e, E, f, r, and w commands shall
take an optional file parameter, separated from the command letter by one or
more <blank>s. If changes have been made in the buffer since the last
w command that wrote the entire buffer, ed shall
warn the user if an attempt is made to destroy the editor buffer via the e
or q commands. The ed utility shall write the
string: "?\n" (followed by an explanatory message if help mode has
been enabled via the H command) to standard output and shall continue in
command mode with the current line number unchanged. If the e or q command
is repeated with no intervening command, it shall take effect. If an
end-of-file is detected on standard input when a command is expected, the
ed utility shall act as if a q command had been
entered. If the closing delimiter of an RE or of a replacement string (e.g.,
/) in a g, G, s, v, or V command would be the last character before a
<newline>, that delimiter can be omitted, in which case the addressed
line shall be written. For example, the following pairs of commands are
equivalent: s/s1/s2 s/s1/s2/p g/s1 g/s1/p ?s1 ?s1? If an invalid command is
entered, ed shall write the string:
"?\n"
(followed by an explanatory message if help mode has been enabled via the H command) to standard output and shall continue in command mode with the current line number unchanged.
APPEND COMMAND
Synopsis: (.)a <text> . The append command shall read the given text and append it after the addressed line; the current line number shall become the address of the last inserted line, or, if there were none, the addressed line. Address 0 shall be valid for this command: it shall cause the ‘‘appended’’ text to be placed at the beginning of the buffer.
CHANGE COMMAND
Synopsis: (.,.)c <text> . The change command shall delete the addressed lines, then accept input text that replaces these lines; the current line shall be set to the address of the last line input; or, if there were none, at the line after the last line deleted; if the lines deleted were originally at the end of the buffer, the current line number shall be set to the address of the new last line; if no lines remain in the buffer, the current line number shall be set to zero.
DELETE COMMAND
Synopsis: (.,.)d The delete command shall delete the addressed lines from the buffer. The address of the line after the last line deleted shall become the current line number; if the lines deleted were originally at the end of the buffer, the current line number shall be set to the address of the new last line; if no lines remain in the buffer, the current line number shall be set to zero.
EDIT COMMAND
Synopsis: e [file] The edit command shall delete the entire contents of the buffer and then read in the file named by the pathname file. The current line number shall be set to the address of the last line of the buffer. If no pathname is given, the currently remembered pathname, if any, shall be used (see the f command). The number of bytes read shall be written to standard output, unless the −s option was specified, in the following format: "%d\n", <number of bytes read>
The name file shall be remembered for possible use as a default pathname in subsequent e, E, r, and w commands. If file is replaced by !, the rest of the line shall be taken to be a shell command line whose output is to be read. Such a shell command line shall not be remembered as the current file. All marks shall be discarded upon the completion of a successful e command. If the buffer has changed since the last time the entire buffer was written, the user shall be warned, as described previously.
EDIT WITHOUT CHECKING COMMAND
Synopsis: E [file] The Edit command shall possess all properties and restrictions of the e command except that the editor shall not check to see if any changes have been made to the buffer since the last w command.
FILE-NAME COMMAND
Synopsis: f [file] If file is given, the file-name command shall change the currently remembered pathname to file; whether the name is changed or not, it then shall write the (possibly new) currently remembered pathname to the standard output in the following format: "%s\n", <pathname> The current line number shall be unchanged.
GLOBAL COMMAND
Synopsis: (1,$)g/RE/command list In the global command, the first step shall be to mark every line that matches the given RE. Then, for every such line, the given command list shall be executed with the current line number set to the address of that line. When the g command completes, the current line number shall have the value assigned by the last command in the command list. If there were no matching lines, the current line number shall not be changed. A single command or the first of a list of commands shall appear on the same line as the global command. All lines of a multiline list except the last line shall be ended with a backslash; the a, i, and c commands and associated input are permitted. The . terminating input mode can be omitted if it would be the last line of the command list. An empty command list shall be equivalent to the p command. The use of the g, G, v, V, and ! commands in the command list produces undefined results. Any character other than <space> or <newline> can be used instead of a slash to delimit the RE. Within the RE, the RE delimiter itself can be used as a literal character if it is preceded by a backslash.
INTERACTIVE GLOBAL COMMAND
Synopsis: (1,$)G/RE/ In the interactive global command, the first step shall be to mark every line that matches the given RE. Then, for every such line, that line shall be written, the current line number shall be set to the address of that line, and any one command (other than one of the a, c, i, g, G, v, and V commands) can be input and shall be executed. A <newline> shall act as a null command (causing no action to be taken on the current line); an & shall cause the reexecution of the most recent nonnull command executed within the current invocation of G. Note that the commands input as part of the execution of the G command can address and affect any lines in the buffer. The final value of the current line number shall be the value set by the last command successfully executed. (Note that the last command successfully executed shall be the G command itself if a command fails or the null command is specified.) If there were no matching lines, the current line number shall not be changed. The G command can be terminated by a SIGINT signal. Any character other than <space> or <newline> can be used instead of a slash to delimit the RE and the replacement. Within the RE, the RE delimiter itself can be used as a literal character if it is preceded by a backslash.
HELP COMMAND
Synopsis: h The help command shall write a short message to standard output that explains the reason for the most recent ? notification. The current line number shall be unchanged.
HELP-MODE COMMAND
Synopsis: H The Help command shall cause
ed to enter a mode in which help messages (see the h
command) shall be written to standard output for all subsequent ?
notifications. The H command alternately shall turn this mode on and off; it
shall be initially off. If the help-mode is being turned on, the H command
also shall explain the previous ? notification, if there was one. The
current line number shall be unchanged.
INSERT COMMAND
Synopsis: (.)i <text> . The insert command shall insert the given text before the addressed line; . shall be left at the last inserted line, or, if there was none, at the addressed line. This command differs from the a command only in the placement of the input text. Address 0 shall be invalid for this command.
JOIN COMMAND
Synopsis: (.,.+1)j The join command shall join contiguous lines by removing the appropriate <newline> characters. If exactly one address is given, this command shall do nothing. If lines are joined, the current line number shall be set to the address of the joined line; otherwise, the current line number shall be unchanged.
MARK COMMAND
Synopsis: (.)kx The mark command shall mark the addressed line with name x, which shall be a lowercase letter from the portable character set. The address ’x then shall refer to this line; the current line number shall be unchanged.
LIST COMMAND
Synopsis: (. ,.)l The list command shall write to standard output the addressed lines in a visually unambiguous form. The characters listed in Table 2-15 (see 2.12) shall be written as the corresponding escape sequence. Nonprintable characters not in Table 2-15 shall be written as one three-digit octal number (with a preceding <backslash>) for each byte in the character (most significant byte first). If the size of a byte on the system is greater than nine bits, the format used for nonprintable characters is implementation defined.
Long lines shall be folded, with the point of folding indicated by writing <backslash><newline>; the length at which folding occurs is unspecified, but should be appropriate for the output device. The end of each line shall be marked with a $. An l command can be appended to any other command other than e, E, f, q, Q, r, w, or !. The current line number shall be set to the address of the last line written.
MOVE COMMAND
Synopsis: (. ,.)maddress The move command shall reposition the addressed line(s) after the line addressed by address. Address 0 shall be valid for address and cause the addressed line(s) to be moved to the beginning of the buffer. It shall be an error if address address falls within the range of moved lines. The current line number shall be set to the address of the last line moved.
NUMBER COMMAND
Synopsis: (.,.)n The number command shall write to standard output the addressed lines, preceding each line by its line number and a <tab> character; the current line number shall be set to the address of the last line written. The n command can be
appended to any other command other than e, E, f, q, Q, r, w, or !.
PRINT COMMAND
Synopsis: (.,.)p The print command shall write to standard output the addressed lines; the current line number shall be set to the address of the last line written. The p command can be appended to any other command other than e, E, f, q, Q, r, w, or !.
PROMPT COMMAND
Synopsis: P The Prompt command shall cause
ed to prompt with an asterisk (∗) (or string,
if −p is specified) for all subsequent commands. The P command
alternately shall turn this mode on and off; it shall be initially on if the
−p option is specified, otherwise off. The current line number shall
be unchanged.
QUIT COMMAND
Synopsis: q The quit command shall cause
ed to exit. If the buffer has changed since the last
time the entire buffer was written, the user shall be warned, as described
previously.
QUIT WITHOUT CHECKING COMMAND
Synopsis: Q The Quit command shall cause
ed to exit without checking if changes have been
made in the buffer since the last w command.
READ COMMAND
Synopsis: ($)r [file] The read command shall read in the file named by the pathname file and append it after the addressed line. If no file argument is given, the currently remembered pathname, if any, shall be used (see e and f commands). The currently remembered pathname shall not be changed unless there is no remembered pathname. Address 0 shall be valid for r and shall cause the file to be read at the beginning of the buffer. If the read is successful, and −s was not specified, the number of bytes read shall be written to standard output in the following format: "%d\n", <number of bytes read> The current line number shall be set to the address of the last line read in. If file is replaced by !, the rest of the line shall be taken to be a shell command line whose output is to be read. Such a shell command line shall not be remembered as the current pathname.
SUBSTITUTE COMMAND
Synopsis: (.,.)s/RE/replacement/flags The substitute command shall search each addressed line for an occurrence of the specified RE and replace either the first or all (nonoverlapped) matched strings with the replacement; see the following description of the g suffix. It is an error if the substitution fails on every addressed line. Any character other than <space> or <newline> can be used instead of a slash to delimit the RE and the replacement. Within the RE, the RE delimiter itself can be used as a literal character if it is preceded by a backslash. The current line shall be set to the address of the last line on which a substitution occurred. An ampersand (&) appearing in the replacement shall be replaced by the string matching the RE on the current line. The special meaning of & in this context can be suppressed by preceding it by backslash. As a more general feature, the characters \n, where n is a digit, shall be replaced by the text matched by the corresponding backreference expression (see 2.8.3.3). When the character % is the only character in the replacement, the replacement used in the most recent substitute command shall be used as the replacement in the current substitute command; if there was no previous substitute command, the use of % in this manner shall be an error. The % shall lose its special meaning when it is in a replacement string of more than one character or is preceded by a backslash. A line can be split by substituting a <newline> character into it. The application shall escape the <newline> in the replacement by preceding it by backslash. Such substitution cannot be done as part of a g or v command list. The current line number shall be set to the address of the last line on which a substitution is performed. If no substitution is performed, the current line number shall be unchanged. If a line is split, a substitution shall be considered to have been performed on each of the new lines for the purpose of determining the new current line number. A substitution shall be considered to have been performed even if the replacement string is identical to the string that it replaces. The value of flags shall be zero or more of: count Substitute for the countth occurrence only of the RE found on each addressed line. g Globally substitute for all nonoverlapping instances of the RE rather than just the first one. If both g and count are specified, the results are unspecified. l Write to standard output the final line in which a substitution was made. The line shall be written in the format specified for the l command. n Write to standard output the final line in which a substitution was made. The line shall be written in the format specified for the n command.
p Write to standard output the final line in which a substitution was made. The line shall be written in the format specified for the p command.
COPY COMMAND
Synopsis: (.,.)taddress The t command shall be equivalent to the m command, except that a copy of the addressed lines shall be placed after address address (which can be 0); the current line number shall be set to the address of the last line added.
UNDO COMMAND
Synopsis: u The undo command shall nullify the effect of the most recent command that modified anything in the buffer, namely the most recent a, c, d, g, i, j, m, r, s, t, u, v, G, or V command. All changes made to the buffer by a g, G, v, or V global command shall be ‘‘undone’’ as a single change; if no changes were made by the global command (such as with g/RE/p), the u command shall have no effect. The current line number shall be set to the value it had immediately before the command being undone started.
GLOBAL NON-MATCHED COMMAND
Synopsis: (1,$)v/RE/command list This command shall be equivalent to the global command g except that the lines that are marked during the first step shall be those that do not match the RE.
INTERACTIVE GLOBAL NOT-MATCHED COMMAND
Synopsis: (1,$)V/RE/ This command shall be equivalent to the interactive global command G except that the lines that are marked during the first step shall be those that do not match the RE.
WRITE COMMAND
Synopsis: (1,$)w [file] The write command shall write the addressed lines into the file named by the pathname file. The command shall create the file, if it does not exist, or shall replace the contents of the existing file. The currently remembered pathname shall not be changed unless there is no remembered pathname. If no pathname is given, the currently remembered pathname, if any, shall be used (see e and f commands); the current line number shall be unchanged. If the command is successful, the number of bytes written shall be written to standard output, unless the −s option was specified, in the following format:
"%d\n", <number of bytes written> If file begins with !, the rest of the line shall be taken to be a shell command line whose standard input shall be the addressed lines. Such a shell command line shall not be remembered as the current pathname. This usage of the write command with ! shall not be considered as a ‘‘last w command that wrote the entire buffer,’’ as described previously; thus, this alone shall not prevent the warning to the user if an attempt is made to destroy the editor buffer via the e or q commands.
LINE NUMBER COMMAND
Synopsis: ($)= The line number of the addressed line shall be written to standard output in the following format: "%d\n", <line number> The current line number shall be unchanged by this command.
SHELL ESCAPE COMMAND
Synopsis: !command The remainder of the line after the ! shall be sent to the command interpreter to be interpreted as a shell command line. Within the text of that shell command line, the unescaped character % shall be replaced with the remembered pathname; if a ! appears as the first character of the command, it shall be replaced with the text of the previous shell command executed via !. Thus, !! shall repeat the previous !command. If any replacements of % and/or ! are performed, the modified line shall be written to the standard output before command is executed. The ! command shall write
"!\n" to standard output upon completion, unless the −s option is specified. The current line number shall be unchanged.
NULL COMMAND
Synopsis: (.+1) An address alone on a line shall cause the addressed line to be written. A <newline> alone shall be equivalent to .+1p. The current line number shall be set to the address of the written line.
EXIT STATUS
The ed utility shall exit with one of the
following values:
CONSEQUENCES OF ERRORS
When an error in the input script is encountered, or when an error is detected that is a consequence of the data (not) present in the file or due to an external condition such as a read or write error:
- If the standard input is a terminal device file, all input shall be flushed, and a new command read.
- If the standard input is a regular file,
edshall terminate with a nonzero exit status.
RATIONALE
EXAMPLES
Some historical implementations contained a bug that allowed a
single period to be entered in input mode as <backslash>
<period> <newline>. This is not allowed by the
POSIX. 2 ed because there is no
description of escaping any of the characters in input mode; backslashes are
entered into the buffer exactly as typed. The typical method of entering a
single period has been to precede it with another character and then use the
substitute command to delete that character. Because of the extremely terse
nature of the default error messages, the prudent script writer will begin
the ed input commands with an H command, so that if
any errors do occur at least some clue as to the cause will be made
available.
HISTORY OF DECISIONS MADE
The initial description of this utility was adapted from the
SVID. It
contains some features not found in Version 7 or BSD
-derived systems. Some of the differences between the
POSIX. 2 and BSD
ed utilities include, but need not be limited
to:
- The BSD - option does not suppress the ! prompt after a ! command.
- BSD does not support the special meanings of the % and ! characters within a ! command.
- BSD does not support the addresses ; and ,.
- BSD allows the command/suffix pairs pp, ll, etc., which are unspecified in POSIX. 2.
- BSD does not support the ! character part of the e, r, or w commands.
- A failed g command in BSD sets the line number to the last line searched if there are no matches.
- BSD does not default the command list to the p command.
- BSD does not support the G, h, H, n, or V commands.
- On BSD, if there is no inserted text, the insert command changes the current line to the referenced line −1; i.e., the line before the specified line.
- On BSD, the join command with only a single address changes the current line to that address.
- BSD does not support the P command; moreover, in BSD it is synonymous with the p command.
- BSD does not support the undo of the commands j, m, r, s, or t.
- The BSD
edcommands W, wq, and z are not present in POSIX. 2.
The −s option was added to allow the
functionality of the − option in a manner compatible with the Utility
Syntax Guidelines. It is the intent of the working group that portable
applications use the −s option, and that in the future the −
option be removed from the standard. Prior to Draft 8 there was a limit,
ED_FILE_MAX,
which described the historical limitations of some
ed utilities in their handling of large files; some
of these have had problems with files in the >100KB range. It was this
limitation that prompted much of the desire to include a split command in
the standard. Since this limit was removed, the standard requires that
implementations document the file size limits imposed by
ed in the conformance document. The limit
ED_LINE_MAX
was also removed; therefore, the global limit LINE_MAX is
used for input and output lines. The \{m,n\} notation was removed from the
description of regular expressions because this functionality is now
described in 2.8.3. The manner in which the l command writes nonprintable
characters was changed to avoid the historical backspace-overstrike method.
On video display terminals, the overstrike is ambiguous because most
terminals simply replace overstruck characters, making the l format not
useful for its intended purpose of unambiguously understanding the content
of the line. The historical backslash escapes were also ambiguous. (The
string "a\0011" could represent a line containing those six
characters or a line containing the three characters ’a’, a
byte with a binary value of 1, and a ’1’.) In the format
required here, a backslash appearing in the line will be written as
"\\" so that the output is truly unambiguous. The method of
marking the ends of lines was adopted from the ex editor (see the User
Portability Extension) and is required for any line ending in
<space>s; the $ is placed on all lines so that a real $ at the end of
a line cannot be misinterpreted.
Systems with bytes too large to fit into three octal digits must devise other means of displaying nonprintable characters. Consideration was given to requiring that the number of octal digits be large enough to hold a byte, but this seemed to be too
confusing for applications on the vast majority of systems where three digits are adequate. It would be theoretically possible for the application to use the getconf utility to find out the CHAR_BIT value and deal with such an algorithm; however, there is really no portable way that an application can use the octal values of the bytes across various coded character sets anyway, so the additional specification did not seem worth the effort.
The description of how a NUL is written was
removed. The NUL character cannot be in text files, and
the standard should not dictate behavior in the case of undefined, erroneous
input. The text requiring filenames accepted by the E, e, R, and r commands
to be patterns was removed due to balloting objections that this was
undesirable and not existing practice. The −p option in Drafts 8 and
9 said that it only worked when standard input was associated with a
terminal device. This has been changed to conform to existing
implementations, thereby allowing applications to interpose themselves
between a user and the ed utility. The form of the
substitute command that uses the n suffix was limited to the first 512
matches in a previous draft (where this was described incorrectly as
‘‘backreferencing’’). This limit has been
removed because there is no reason an editor processing lines of
LINE_MAX length should have this restriction. The command
s/x/X/2047 should be able to substitute the 2047th occurrence of x on a
line. The use of printing commands with printing suffixes (such as pn, lp,
etc.) was made unspecified because BSD -based systems
allow this, whereas System V does not. Some BSD -based
systems exit immediately upon receipt of end-of-file if all of the lines in
the file had been deleted. Since POSIX. 2 refers to the q
command in this instance, such behavior is not allowed. Some historical
implementations returned exit status zero even if command errors had
occurred; this is not allowed by POSIX. 2.