Un outil pour savoir si une commande est posix - retour accueil
git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |
ed.html (75764B)
1 <!-- Copyright 2001-2024 IEEE and The Open Group, All Rights Reserved --> 2 <!DOCTYPE HTML> 3 <html lang="en"> 4 <head> 5 <meta name="generator" content="HTML Tidy for HTML5 for Linux version 5.8.0"> 6 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 7 <link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group rhtm tool v1.2.4 --> 8 <!-- Copyright (c) 2001-2024 The Open Group, All Rights Reserved --> 9 <title>ed</title> 10 </head> 11 <body bgcolor="white"> 12 <div class="NAVHEADER"> 13 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 14 <tr class="nav"> 15 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/echo.html" accesskey="P"><<< 16 Previous</a></td> 17 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 18 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/env.html" accesskey="N">Next >>></a></td> 19 </tr> 20 </table> 21 <hr align="left" width="100%"></div> 22 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> 23 <center><font size="2">The Open Group Base Specifications Issue 8<br> 24 IEEE Std 1003.1-2024<br> 25 Copyright © 2001-2024 The IEEE and The Open Group</font></center> 26 <hr size="2" noshade> 27 <a name="top" id="top"></a> <a name="ed" id="ed"></a> <a name="tag_20_38" id="tag_20_38"></a><!-- ed --> 28 <h4 class="mansect"><a name="tag_20_38_01" id="tag_20_38_01"></a>NAME</h4> 29 <blockquote>ed — edit text</blockquote> 30 <h4 class="mansect"><a name="tag_20_38_02" id="tag_20_38_02"></a>SYNOPSIS</h4> 31 <blockquote class="synopsis"> 32 <p><code><tt>ed</tt> <b>[</b><tt>-p</tt> <i>string</i><b>] [</b><tt>-s</tt><b>] [</b><i>file</i><b>]</b></code></p> 33 </blockquote> 34 <h4 class="mansect"><a name="tag_20_38_03" id="tag_20_38_03"></a>DESCRIPTION</h4> 35 <blockquote> 36 <p>The <i>ed</i> utility is a line-oriented text editor that uses two modes: <i>command mode</i> and <i>input mode</i>. In command 37 mode the input characters shall be interpreted as commands, and in input mode they shall be interpreted as text. See the EXTENDED 38 DESCRIPTION section.</p> 39 <p>If an operand is <tt>'-'</tt>, the results are unspecified.</p> 40 </blockquote> 41 <h4 class="mansect"><a name="tag_20_38_04" id="tag_20_38_04"></a>OPTIONS</h4> 42 <blockquote> 43 <p>The <i>ed</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax 44 Guidelines</i></a> , except for the unspecified usage of <tt>'-'</tt>.</p> 45 <p>The following options shall be supported:</p> 46 <dl compact> 47 <dd></dd> 48 <dt><b>-p </b><i>string</i></dt> 49 <dd>Use <i>string</i> as the prompt string when in command mode. By default, there shall be no prompt string.</dd> 50 <dt><b>-s</b></dt> 51 <dd>Suppress the writing of byte counts by <b>e</b>, <b>E</b>, <b>r</b>, and <b>w</b> commands and of the <tt>'!'</tt> prompt after 52 a !<i>command</i>.</dd> 53 </dl> 54 </blockquote> 55 <h4 class="mansect"><a name="tag_20_38_05" id="tag_20_38_05"></a>OPERANDS</h4> 56 <blockquote> 57 <p>The following operand shall be supported:</p> 58 <dl compact> 59 <dd></dd> 60 <dt><i>file</i></dt> 61 <dd>If the <i>file</i> argument is given, <i>ed</i> shall perform the effect of an <b>e</b> command on the pathname <i>file</i> 62 before accepting commands from the standard input, except that <i>file</i> can contain a <newline>, even though this is not 63 possible for the argument to the <b>e</b> command.</dd> 64 </dl> 65 </blockquote> 66 <h4 class="mansect"><a name="tag_20_38_06" id="tag_20_38_06"></a>STDIN</h4> 67 <blockquote> 68 <p>The standard input shall be a text file consisting of commands, as described in the EXTENDED DESCRIPTION section.</p> 69 </blockquote> 70 <h4 class="mansect"><a name="tag_20_38_07" id="tag_20_38_07"></a>INPUT FILES</h4> 71 <blockquote> 72 <p>The input files shall be text files.</p> 73 </blockquote> 74 <h4 class="mansect"><a name="tag_20_38_08" id="tag_20_38_08"></a>ENVIRONMENT VARIABLES</h4> 75 <blockquote> 76 <p>The following environment variables shall affect the execution of <i>ed</i>:</p> 77 <dl compact> 78 <dd></dd> 79 <dt><i>HOME</i></dt> 80 <dd>Determine the pathname of the user's home directory.</dd> 81 <dt><i>LANG</i></dt> 82 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href= 83 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization 84 variables used to determine the values of locale categories.)</dd> 85 <dt><i>LC_ALL</i></dt> 86 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd> 87 <dt><i>LC_COLLATE</i></dt> 88 <dd><br> 89 Determine the locale for the behavior of ranges, equivalence classes, and multi-character collating elements within regular 90 expressions.</dd> 91 <dt><i>LC_CTYPE</i></dt> 92 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as 93 opposed to multi-byte characters in arguments and input files) and the behavior of character classes within regular 94 expressions.</dd> 95 <dt><i>LC_MESSAGES</i></dt> 96 <dd><br> 97 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error and 98 informative messages written to standard output.</dd> 99 <dt><i>NLSPATH</i></dt> 100 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> 101 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border= 102 "0"></dd> 103 </dl> 104 </blockquote> 105 <h4 class="mansect"><a name="tag_20_38_09" id="tag_20_38_09"></a>ASYNCHRONOUS EVENTS</h4> 106 <blockquote> 107 <p>The <i>ed</i> utility shall take the standard action for all signals (see the ASYNCHRONOUS EVENTS section in <a href= 108 "../utilities/V3_chap01.html#tag_18_04"><i>1.4 Utility Description Defaults</i></a> ) with the following exceptions:</p> 109 <dl compact> 110 <dd></dd> 111 <dt>SIGINT</dt> 112 <dd>The <i>ed</i> utility shall interrupt its current activity, write the string <tt>"?\n"</tt> to standard output, and return to 113 command mode (see the EXTENDED DESCRIPTION section).</dd> 114 <dt>SIGHUP</dt> 115 <dd>If the buffer is not empty and the buffer change flag is currently set to either <b>changed</b> or <b>changed-and-warned</b> 116 (see the EXTENDED DESCRIPTION section), the <i>ed</i> utility shall attempt to write a copy of the buffer in a file. First, the 117 file named <b>ed.hup</b> in the current directory shall be used; if that fails, the file named <b>ed.hup</b> in the directory named 118 by the <i>HOME</i> environment variable shall be used. In any case, the <i>ed</i> utility shall exit without writing the file to 119 the currently remembered pathname and without returning to command mode.</dd> 120 <dt>SIGQUIT</dt> 121 <dd>The <i>ed</i> utility shall ignore this event.</dd> 122 </dl> 123 </blockquote> 124 <h4 class="mansect"><a name="tag_20_38_10" id="tag_20_38_10"></a>STDOUT</h4> 125 <blockquote> 126 <p>Various editing commands and the prompting feature (see <b>-p</b>) write to standard output, as described in the EXTENDED 127 DESCRIPTION section.</p> 128 </blockquote> 129 <h4 class="mansect"><a name="tag_20_38_11" id="tag_20_38_11"></a>STDERR</h4> 130 <blockquote> 131 <p>The standard error shall be used for diagnostic messages and may be used for warning messages.</p> 132 </blockquote> 133 <h4 class="mansect"><a name="tag_20_38_12" id="tag_20_38_12"></a>OUTPUT FILES</h4> 134 <blockquote> 135 <p>The output files shall be text files whose formats are dependent on the editing commands given.</p> 136 </blockquote> 137 <h4 class="mansect"><a name="tag_20_38_13" id="tag_20_38_13"></a>EXTENDED DESCRIPTION</h4> 138 <blockquote> 139 <p>The <i>ed</i> utility shall operate on a copy of the file it is editing; changes made to the copy shall have no effect on the 140 file until a <b>w</b> (write) command is given. The copy of the text is called the <i>buffer</i>. The <i>ed</i> utility shall keep 141 track of whether the buffer has been modified. This shall be maintained as if via a tri-state internal flag with the state values 142 <b>unchanged</b>, <b>changed</b>, and <b>changed-and-warned</b>, which is:</p> 143 <ul> 144 <li> 145 <p>Initially set to <b>unchanged</b></p> 146 </li> 147 <li> 148 <p>Set to <b>changed</b> by any command that modifies the buffer</p> 149 </li> 150 <li> 151 <p>Set to <b>unchanged</b> by an <b>e</b> or <b>E</b> command that reloads (or empties) the buffer, or a <b>w</b> command that 152 writes the entire buffer</p> 153 </li> 154 <li> 155 <p>Set to either <b>changed-and-warned</b> or <b>unchanged</b> by an <b>e</b> or <b>q</b> command that warns an attempt was made to 156 destroy the editor buffer</p> 157 </li> 158 </ul> 159 <p>A command that makes changes to the buffer in such a way that its contents are the same after the command (for example 160 <b>s/a/a/</b>) shall be considered to have modified the buffer, unless explicitly stated otherwise. In the remainder of the 161 description, this flag is referred to as the <i>buffer change flag</i>.</p> 162 <p>Commands to <i>ed</i> have a simple and regular structure: zero, one, or two <i>addresses</i> followed by a single-character 163 <i>command</i>, possibly followed by parameters to that command. These addresses specify one or more lines in the buffer. Every 164 command that requires addresses has default addresses, so that the addresses very often can be omitted. If the <b>-p</b> option is 165 specified, the prompt string shall be written to standard output before each command is read.</p> 166 <p>In general, only one command can appear on a line. Certain commands allow text to be input. This text is placed in the 167 appropriate place in the buffer. While <i>ed</i> is accepting text, it is said to be in <i>input mode</i>. In this mode, no 168 commands shall be recognized; all input is merely collected. Input mode is terminated by entering a line consisting of two 169 characters: a <period> (<tt>'.'</tt>) followed by a <newline>. This line is not considered part of the input text.</p> 170 <h5><a name="tag_20_38_13_01" id="tag_20_38_13_01"></a>Regular Expressions in ed</h5> 171 <p>The <i>ed</i> utility shall support basic regular expressions, as described in XBD <a href= 172 "../basedefs/V1_chap09.html#tag_09_03"><i>9.3 Basic Regular Expressions</i></a> . Since regular expressions in <i>ed</i> are always 173 matched against single lines (excluding the terminating <newline> characters), never against any larger section of text, 174 there is no way for a regular expression to match a <newline>.</p> 175 <p>A null RE shall be equivalent to the last RE encountered.</p> 176 <p>Regular expressions are used in addresses to specify lines, and in some commands (for example, the <b>s</b> substitute command) 177 to specify portions of a line to be substituted.</p> 178 <p>The start and end of a regular expression (RE) are marked by a delimiter character (although in some circumstances the end 179 delimiter can be omitted). In addresses, the delimiter is either <slash> or <question-mark>. In commands, other 180 characters can be used as the delimiter, as specified in the description of the command. Within the RE (as an <i>ed</i> extension 181 to the BRE syntax), the delimiter shall not terminate the RE if it is the second character of an escape sequence (see XBD <a href= 182 "../basedefs/V1_chap09.html#tag_09_01"><i>9.1 Regular Expression Definitions</i></a> ) and the escaped delimiter shall be treated 183 as that literal character in the RE (losing any special meaning it would have had if it was not used as the delimiter and was not 184 escaped). In addition, the delimiter character shall not terminate the RE when it appears within a bracket expression, and shall 185 have its normal meaning in the bracket expression. For example, the command <tt>"g%[%]%p"</tt> is equivalent to <tt>"g/[%]/p"</tt>, 186 and the command <tt>"s-[0-9]--g"</tt> is equivalent to <tt>"s/[0-9]//g"</tt>.</p> 187 <h5><a name="tag_20_38_13_02" id="tag_20_38_13_02"></a>Addresses in ed</h5> 188 <p>Addressing in <i>ed</i> relates to the current line. Generally, the current line is the last line affected by a command. The 189 current line number is the address of the current line. If the edit buffer is not empty, the initial value for the current line 190 shall be the last line in the edit buffer; otherwise, zero.</p> 191 <p>Addresses shall be constructed as follows:</p> 192 <ol> 193 <li> 194 <p>The <period> character (<tt>'.'</tt>) shall address the current line.</p> 195 </li> 196 <li> 197 <p>The <dollar-sign> character (<tt>'$'</tt>) shall address the last line of the edit buffer.</p> 198 </li> 199 <li> 200 <p>The positive decimal number <i>n</i> shall address the <i>n</i>th line of the edit buffer.</p> 201 </li> 202 <li> 203 <p>The <apostrophe>-x character pair (<tt>"'x"</tt>) shall address the line marked with the mark name character <i>x</i>, 204 which shall be a lowercase letter from the portable character set. It shall be an error if the character has not been set to mark a 205 line or if the line that was marked is not currently present in the edit buffer.</p> 206 </li> 207 <li> 208 <p>A BRE enclosed by <slash> characters (<tt>'/'</tt>) shall address the first line found by searching forwards from the line 209 following the current line toward the end of the edit buffer and stopping at the first line for which the line excluding the 210 terminating <newline> matches the BRE. The BRE consisting of a null BRE delimited by a pair of <slash> characters shall 211 address the next line for which the line excluding the terminating <newline> matches the last BRE encountered. In addition, 212 the second <slash> can be omitted at the end of a command line. Within the BRE, a <backslash>-<slash> pair 213 (<tt>"\/"</tt>) shall represent a literal <slash> instead of the BRE delimiter. If necessary, the search shall wrap around to 214 the beginning of the buffer and continue up to and including the current line, so that the entire buffer is searched.</p> 215 </li> 216 <li> 217 <p>A BRE enclosed by <question-mark> characters (<tt>'?'</tt>) shall address the first line found by searching backwards from 218 the line preceding the current line toward the beginning of the edit buffer and stopping at the first line for which the line 219 excluding the terminating <newline> matches the BRE. The BRE consisting of a null BRE delimited by a pair of 220 <question-mark> characters (<tt>"??"</tt>) shall address the previous line for which the line excluding the terminating 221 <newline> matches the last BRE encountered. In addition, the second <question-mark> can be omitted at the end of a 222 command line. Within the BRE, a <backslash>-<question-mark> pair (<tt>"\?"</tt>) shall represent a literal 223 <question-mark> instead of the BRE delimiter. If necessary, the search shall wrap around to the end of the buffer and 224 continue up to and including the current line, so that the entire buffer is searched.</p> 225 </li> 226 <li> 227 <p>A <plus-sign> (<tt>'+'</tt>) or <hyphen-minus> character (<tt>'-'</tt>) followed by a decimal number shall address 228 the current line plus or minus the number. A <plus-sign> or <hyphen-minus> character not followed by a decimal number 229 shall address the current line plus or minus 1.</p> 230 </li> 231 </ol> 232 <p>Addresses can be followed by zero or more address offsets, optionally <blank>-separated. Address offsets are constructed 233 as follows:</p> 234 <ul> 235 <li> 236 <p>A <plus-sign> or <hyphen-minus> character followed by a decimal number shall add or subtract, respectively, the 237 indicated number of lines to or from the address. A <plus-sign> or <hyphen-minus> character not followed by a decimal 238 number shall add or subtract 1 to or from the address.</p> 239 </li> 240 <li> 241 <p>A decimal number shall add the indicated number of lines to the address.</p> 242 </li> 243 </ul> 244 <p>It shall not be an error for an intermediate address value to be less than zero or greater than the last line in the edit 245 buffer. It shall be an error for the final address value to be less than zero or greater than the last line in the edit buffer. It 246 shall be an error if a search for a BRE fails to find a matching line.</p> 247 <p>Commands accept zero, one, or two addresses. If one or more addresses are provided to a command that requires zero addresses, it 248 shall be an error. Otherwise, if more than the maximum number of accepted addresses are provided to a command, the addresses shall 249 be evaluated from first to last and then discarded, until the maximum number of accepted addresses for that command remain.</p> 250 <p>Addresses shall be separated from each other by a <comma> (<tt>','</tt>) or <semicolon> character (<tt>';'</tt>). In 251 the case of a <semicolon> separator, the current line (<tt>'.'</tt>) shall be set to the first address, and only then shall 252 the second address be calculated. This feature can be used to determine the starting line for forwards and backwards searches; see 253 rules 5. and 6.</p> 254 <p>Addresses can be omitted on either side of the <comma> or <semicolon> separator, in which case the resulting address 255 pairs shall be as follows:</p> 256 <center> 257 <table border="1" cellpadding="3" align="center"> 258 <tr valign="top"> 259 <th align="center"> 260 <p class="tent"><b>Specified</b></p> 261 </th> 262 <th align="center"> 263 <p class="tent"><b>Resulting</b></p> 264 </th> 265 </tr> 266 <tr valign="top"> 267 <td align="left"> 268 <p class="tent">,</p> 269 </td> 270 <td align="left"> 271 <p class="tent">1 , $</p> 272 </td> 273 </tr> 274 <tr valign="top"> 275 <td align="left"> 276 <p class="tent">, addr</p> 277 </td> 278 <td align="left"> 279 <p class="tent">1 , addr</p> 280 </td> 281 </tr> 282 <tr valign="top"> 283 <td align="left"> 284 <p class="tent">addr ,</p> 285 </td> 286 <td align="left"> 287 <p class="tent">addr , addr</p> 288 </td> 289 </tr> 290 <tr valign="top"> 291 <td align="left"> 292 <p class="tent">;</p> 293 </td> 294 <td align="left"> 295 <p class="tent">. ; $</p> 296 </td> 297 </tr> 298 <tr valign="top"> 299 <td align="left"> 300 <p class="tent">; addr</p> 301 </td> 302 <td align="left"> 303 <p class="tent">. ; addr</p> 304 </td> 305 </tr> 306 <tr valign="top"> 307 <td align="left"> 308 <p class="tent">addr ;</p> 309 </td> 310 <td align="left"> 311 <p class="tent">addr ; addr</p> 312 </td> 313 </tr> 314 </table> 315 </center> 316 <p class="tent">If an address is omitted between two separators, the rule shall be applied to the first separator and the resulting 317 second address shall be used as the first address for the second separator. For example, with the address list <tt>",,"</tt> the 318 first <tt>','</tt> becomes <tt>"1,$"</tt> and the <tt>'$'</tt> is treated as the first address for the second <tt>','</tt>, 319 resulting in <tt>"1,$,$"</tt>.</p> 320 <p class="tent">Any <blank> characters included between addresses, address separators, or address offsets shall be 321 ignored.</p> 322 <h5><a name="tag_20_38_13_03" id="tag_20_38_13_03"></a>Commands in ed</h5> 323 <p class="tent">In the following list of <i>ed</i> commands, the default addresses are shown in parentheses. The number of 324 addresses shown in the default shall be the number expected by the command. The parentheses are not part of the address; they show 325 that the given addresses are the default.</p> 326 <p class="tent">It is generally invalid for more than one command to appear on a line. However, any command (except <b>e</b>, 327 <b>E</b>, <b>f</b>, <b>q</b>, <b>Q</b>, <b>r</b>, <b>w</b>, and <b>!</b>) can be suffixed by the letter <b>l</b>, <b>n</b>, or 328 <b>p</b>; in which case, except for the <b>l</b>, <b>n</b>, and <b>p</b> commands, the command shall be executed and then the new 329 current line shall be written as described below under the <b>l</b>, <b>n</b>, and <b>p</b> commands. When an <b>l</b>, <b>n</b>, 330 or <b>p</b> suffix is used with an <b>l</b>, <b>n</b>, or <b>p</b> command, the command shall write to standard output as described 331 below, but it is unspecified whether the suffix writes the current line again in the requested format or whether the suffix has no 332 effect. For example, the <b>pl</b> command (base <b>p</b> command with an <b>l</b> suffix) shall either write just the current line 333 or write it twice—once as specified for <b>p</b> and once as specified for <b>l</b>. Also, the <b>g</b>, <b>G</b>, <b>v</b>, and 334 <b>V</b> commands shall take a command as a parameter.</p> 335 <p class="tent">Each address component can be preceded by zero or more <blank> characters. The command letter can be preceded 336 by zero or more <blank> characters. If a suffix letter (<b>l</b>, <b>n</b>, or <b>p</b>) is given, the application shall 337 ensure that it immediately follows the command.</p> 338 <p class="tent">The <b>e</b>, <b>E</b>, <b>f</b>, <b>r</b>, and <b>w</b> commands shall take an optional <i>file</i> parameter, 339 separated from the command letter by one or more <blank> characters.</p> 340 <p class="tent">If the buffer change flag is currently set to <b>changed</b>, <i>ed</i> shall warn the user if an attempt is made 341 to destroy the editor buffer via the <b>e</b> or <b>q</b> commands. The <i>ed</i> utility shall write the string:</p> 342 <pre> 343 <tt>"?\n" 344 </tt></pre> 345 <p class="tent">(followed by an explanatory message if <i>help mode</i> has been enabled via the <b>H</b> command) to standard 346 output and shall continue in command mode with the buffer change flag set to either <b>changed-and-warned</b> or <b>unchanged</b> 347 and the current line number unchanged. If another <b>e</b> or <b>q</b> command is then attempted with no intervening command that 348 sets the buffer change flag to <b>changed</b>, it shall take effect.</p> 349 <p class="tent">If a terminal disconnect (see XBD <a href="../basedefs/V1_chap11.html#tag_11"><i>11. General Terminal 350 Interface</i></a> , Modem Disconnect and Closing a Device Terminal), is detected:</p> 351 <ul> 352 <li class="tent">If accompanied by a SIGHUP signal, the <i>ed</i> utility shall operate as described in the ASYNCHRONOUS EVENTS 353 section for a SIGHUP signal.</li> 354 <li class="tent">If not accompanied by a SIGHUP signal, the <i>ed</i> utility shall act as if an end-of-file had been detected on 355 standard input.</li> 356 </ul> 357 <p class="tent">If an end-of-file is detected on standard input:</p> 358 <ul> 359 <li class="tent">If the <i>ed</i> utility is in input mode, <i>ed</i> shall terminate input mode and return to command mode. It is 360 unspecified if any partially entered lines (that is, input text without a terminating <newline>) are discarded from the input 361 text.</li> 362 <li class="tent">If the <i>ed</i> utility is in command mode, it shall act as if a <b>q</b> command had been entered.</li> 363 </ul> 364 <p class="tent">In the following commands, if a closing delimiter would be the last character before a <newline> then that 365 character can be omitted with the behavior shown:</p> 366 <ul> 367 <li class="tent">For the <b>g</b> and <b>v</b> commands the addressed line(s) shall be written as if a closing delimiter followed 368 by a <b>p</b> were appended to the command.</li> 369 <li class="tent">For the <b>G</b> and <b>V</b> commands no additional action shall be taken.</li> 370 <li class="tent">For the <b>s</b> command, only the closing delimiter of the replacement can be omitted, in which case the result 371 of the substitution shall be written as if the <b>p</b> flag were appended.</li> 372 <li class="tent">For the null command, the addressed line(s) shall be written as if the closing delimiter were appended.</li> 373 </ul> 374 <p class="tent">For example, the following pairs of commands are equivalent:</p> 375 <pre> 376 <tt>s/s1/s2 s/s1/s2/p 377 g/s1 g/s1/p 378 ?s1 ?s1? 379 </tt></pre> 380 <p class="tent">If an invalid command is entered, <i>ed</i> shall write the string:</p> 381 <pre> 382 <tt>"?\n" 383 </tt></pre> 384 <p class="tent">(followed by an explanatory message if <i>help mode</i> has been enabled via the <b>H</b> command) to standard 385 output and shall continue in command mode with the current line number unchanged.</p> 386 <h5><a name="tag_20_38_13_04" id="tag_20_38_13_04"></a>Append Command</h5> 387 <dl compact> 388 <dd></dd> 389 <dt><i>Synopsis</i>:</dt> 390 <dd> 391 <p class="tent"></p> 392 <pre> 393 <tt>(.)a 394 <</tt><i>text</i><tt>> 395 . 396 </tt></pre></dd> 397 </dl> 398 <p class="tent">The <b>a</b> command shall read the given text and append it after the addressed line; the current line number 399 shall become the address of the last inserted line or, if there were none, the addressed line. Address 0 shall be valid for this 400 command; it shall cause the appended text to be placed at the beginning of the buffer. If <<i>text</i>> is empty (that is, 401 the terminating <tt>'.'</tt> immediately follows the <tt>'a'</tt>), the buffer change flag shall not be altered.</p> 402 <h5><a name="tag_20_38_13_05" id="tag_20_38_13_05"></a>Change Command</h5> 403 <dl compact> 404 <dd></dd> 405 <dt><i>Synopsis</i>:</dt> 406 <dd> 407 <p class="tent"></p> 408 <pre> 409 <tt>(.,.)c 410 <</tt><i>text</i><tt>> 411 . 412 </tt></pre></dd> 413 </dl> 414 <p class="tent">The <b>c</b> command shall delete the addressed lines, then accept input text that replaces these lines; the 415 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; 416 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 417 line; if no lines remain in the buffer, the current line number shall be set to zero.</p> 418 <h5><a name="tag_20_38_13_06" id="tag_20_38_13_06"></a>Delete Command</h5> 419 <dl compact> 420 <dd></dd> 421 <dt><i>Synopsis</i>:</dt> 422 <dd> 423 <p class="tent"></p> 424 <pre> 425 <tt>(.,.)d 426 </tt></pre></dd> 427 </dl> 428 <p class="tent">The <b>d</b> command shall delete the addressed lines from the buffer. The address of the line after the last line 429 deleted shall become the current line number; if the lines deleted were originally at the end of the buffer, the current line 430 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 431 zero.</p> 432 <h5><a name="tag_20_38_13_07" id="tag_20_38_13_07"></a>Edit Command</h5> 433 <dl compact> 434 <dd></dd> 435 <dt><i>Synopsis</i>:</dt> 436 <dd> 437 <p class="tent"></p> 438 <pre> 439 <tt>e </tt><b>[</b><i>file</i><b>]</b><tt> 440 </tt></pre></dd> 441 </dl> 442 <p class="tent">The <b>e</b> command shall delete the entire contents of the buffer and then read in the file named by the pathname 443 <i>file</i>. The current line number shall be set to the address of the last line of the buffer. If no pathname is given, the 444 currently remembered pathname, if any, shall be used (see the <b>f</b> command). If the pathname names a file that does not exist 445 and the buffer change flag is currently set to <b>unchanged</b>, it is unspecified whether this is treated as an error, or whether 446 the resulting buffer is emptied and a warning is written to standard error instead of writing the byte count to standard out. The 447 number of bytes read shall be written to standard output, unless the <b>-s</b> option was specified, in the following format:</p> 448 <pre> 449 <tt>"%d\n", <</tt><i>number of bytes read</i><tt>> 450 </tt></pre> 451 <p class="tent">The name <i>file</i> shall be remembered for possible use as a default pathname in subsequent <b>e</b>, <b>E</b>, 452 <b>r</b>, and <b>w</b> commands. If <i>file</i> is replaced by <tt>'!'</tt>, the rest of the line shall be taken to be a shell 453 command line whose output is to be read. Such a shell command line shall not be remembered as the current <i>file</i>. All marks 454 shall be discarded upon the completion of a successful <b>e</b> command. If the buffer change flag is currently set to 455 <b>changed</b>, the user shall be warned, as described previously.</p> 456 <h5><a name="tag_20_38_13_08" id="tag_20_38_13_08"></a>Edit Without Checking Command</h5> 457 <dl compact> 458 <dd></dd> 459 <dt><i>Synopsis</i>:</dt> 460 <dd> 461 <p class="tent"></p> 462 <pre> 463 <tt>E </tt><b>[</b><i>file</i><b>]</b><tt> 464 </tt></pre></dd> 465 </dl> 466 <p class="tent">The <b>E</b> command shall possess all properties and restrictions of the <b>e</b> command except that the editor 467 shall not check the current state of the buffer change flag.</p> 468 <h5><a name="tag_20_38_13_09" id="tag_20_38_13_09"></a>Filename Command</h5> 469 <dl compact> 470 <dd></dd> 471 <dt><i>Synopsis</i>:</dt> 472 <dd> 473 <p class="tent"></p> 474 <pre> 475 <tt>f </tt><b>[</b><i>file</i><b>]</b><tt> 476 </tt></pre></dd> 477 </dl> 478 <p class="tent">If <i>file</i> is given, the <b>f</b> command shall change the currently remembered pathname to <i>file</i>, 479 whether or not <i>file</i> names an existing file; whether the name is changed or not, it shall then write the (possibly new) 480 currently remembered pathname to the standard output in the following format:</p> 481 <pre> 482 <tt>"%s\n", <</tt><i>pathname</i><tt>> 483 </tt></pre> 484 <p class="tent">The current line number shall be unchanged.</p> 485 <h5><a name="tag_20_38_13_10" id="tag_20_38_13_10"></a>Global Command</h5> 486 <dl compact> 487 <dd></dd> 488 <dt><i>Synopsis</i>:</dt> 489 <dd> 490 <p class="tent"></p> 491 <pre> 492 <tt>(1,$)g/</tt><i>RE</i><tt>/</tt><i>command list</i><tt> 493 </tt></pre></dd> 494 </dl> 495 <p class="tent">In the <b>g</b> command, the first step shall be to mark every line for which the line excluding the terminating 496 <newline> matches the given RE. Then, going sequentially from the beginning of the file to the end of the file, the given 497 <i>command list</i> shall be executed for each marked line, with the current line number set to the address of that line. Any line 498 modified by the <i>command list</i> shall be unmarked. When the <b>g</b> command completes, the current line number shall have the 499 value assigned by the last command in the <i>command list</i>. If there were no matching lines, the current line number shall not 500 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 501 multi-line list except the last line shall be ended with a <backslash> preceding the terminating <newline>; the 502 <b>a</b>, <b>i</b>, and <b>c</b> commands and associated input are permitted. The <tt>'.'</tt> terminating input mode can be 503 omitted if it would be the last line of the <i>command list</i>. An empty <i>command list</i> shall be equivalent to the <b>p</b> 504 command. The use of the <b>g</b>, <b>G</b>, <b>v</b>, <b>V</b>, and <b>!</b> commands in the <i>command list</i> produces undefined 505 results. Any character other than <backslash>, <space>, or <newline> can be used instead of a <slash> to 506 delimit the RE. Within the RE, in certain circumstances the RE delimiter can be used as a literal character; see <a href= 507 "#tag_20_38_13_01">Regular Expressions in ed</a> .</p> 508 <h5><a name="tag_20_38_13_11" id="tag_20_38_13_11"></a>Interactive Global Command</h5> 509 <dl compact> 510 <dd></dd> 511 <dt><i>Synopsis</i>:</dt> 512 <dd> 513 <p class="tent"></p> 514 <pre> 515 <tt>(1,$)G/</tt><i>RE</i><tt>/ 516 </tt></pre></dd> 517 </dl> 518 <p class="tent">In the <b>G</b> command, the first step shall be to mark every line for which the line excluding the terminating 519 <newline> matches the given RE. Then, for every such line, that line shall be written, the current line number shall be set 520 to the address of that line, and any one command (other than one of the <b>a</b>, <b>c</b>, <b>i</b>, <b>g</b>, <b>G</b>, <b>v</b>, 521 and <b>V</b> commands) shall be read and executed. A <newline> shall act as a null command (causing no action to be taken on 522 the current line); an <tt>'&'</tt> shall cause the re-execution of the most recent non-null command executed within the current 523 invocation of <b>G</b>. Note that the commands input as part of the execution of the <b>G</b> command can address and affect any 524 lines in the buffer. Any line modified by the command shall be unmarked. The final value of the current line number shall be the 525 value set by the last command successfully executed. (Note that the last command successfully executed shall be the <b>G</b> 526 command itself if a command fails or the null command is specified.) If there were no matching lines, the current line number shall 527 not be changed. The <b>G</b> command can be terminated by a SIGINT signal. Any character other than <backslash>, 528 <space>, or <newline> can be used instead of a <slash> to delimit the RE. Within the RE, in certain circumstances 529 the RE delimiter can be used as a literal character; see <a href="#tag_20_38_13_01">Regular Expressions in ed</a> .</p> 530 <h5><a name="tag_20_38_13_12" id="tag_20_38_13_12"></a>Help Command</h5> 531 <dl compact> 532 <dd></dd> 533 <dt><i>Synopsis</i>:</dt> 534 <dd> 535 <p class="tent"></p> 536 <pre> 537 <tt>h 538 </tt></pre></dd> 539 </dl> 540 <p class="tent">The <b>h</b> command shall write a short message to standard output that explains the reason for the most recent 541 <tt>'?'</tt> notification. The current line number shall be unchanged.</p> 542 <h5><a name="tag_20_38_13_13" id="tag_20_38_13_13"></a>Help-Mode Command</h5> 543 <dl compact> 544 <dd></dd> 545 <dt><i>Synopsis</i>:</dt> 546 <dd> 547 <p class="tent"></p> 548 <pre> 549 <tt>H 550 </tt></pre></dd> 551 </dl> 552 <p class="tent">The <b>H</b> command shall cause <i>ed</i> to enter a mode in which help messages (see the <b>h</b> command) shall 553 be written to standard output for all subsequent <tt>'?'</tt> notifications. The <b>H</b> command alternately shall turn this mode 554 on and off; it is initially off. If the help-mode is being turned on, the <b>H</b> command also explains the previous <tt>'?'</tt> 555 notification, if there was one. The current line number shall be unchanged.</p> 556 <h5><a name="tag_20_38_13_14" id="tag_20_38_13_14"></a>Insert Command</h5> 557 <dl compact> 558 <dd></dd> 559 <dt><i>Synopsis</i>:</dt> 560 <dd> 561 <p class="tent"></p> 562 <pre> 563 <tt>(.)i 564 <</tt><i>text</i><tt>> 565 . 566 </tt></pre></dd> 567 </dl> 568 <p class="tent">The <b>i</b> command shall insert the given text before the addressed line; the current line is set to the last 569 inserted line or, if there was none, to the addressed line. This command differs from the <b>a</b> command only in the placement of 570 the input text. Address 0 shall be valid for this command; it is unspecified whether it causes the inserted text to be placed at 571 the beginning of the buffer or it is interpreted as if address 1 were specified. (These two allowed behaviors differ in the case 572 that the buffer is empty.) If <<i>text</i>> is empty (that is, the terminating <tt>'.'</tt> immediately follows the 573 <tt>'i'</tt>), the buffer change flag shall not be altered.</p> 574 <h5><a name="tag_20_38_13_15" id="tag_20_38_13_15"></a>Join Command</h5> 575 <dl compact> 576 <dd></dd> 577 <dt><i>Synopsis</i>:</dt> 578 <dd> 579 <p class="tent"></p> 580 <pre> 581 <tt>(.,.+1)j 582 </tt></pre></dd> 583 </dl> 584 <p class="tent">The <b>j</b> command shall join contiguous lines by removing the appropriate <newline> characters. If exactly 585 one address is given, this command shall do nothing. If lines are joined, the current line number shall be set to the address of 586 the joined line; otherwise, the current line number shall be unchanged.</p> 587 <h5><a name="tag_20_38_13_16" id="tag_20_38_13_16"></a>Mark Command</h5> 588 <dl compact> 589 <dd></dd> 590 <dt><i>Synopsis</i>:</dt> 591 <dd> 592 <p class="tent"></p> 593 <pre> 594 <tt>(.)k</tt><i>x</i><tt> 595 </tt></pre></dd> 596 </dl> 597 <p class="tent">The <b>k</b> command shall mark the addressed line with name <i>x</i>, which the application shall ensure is a 598 lowercase letter from the portable character set. The address <tt>"'x"</tt> shall then refer to this line; the current line number 599 shall be unchanged.</p> 600 <h5><a name="tag_20_38_13_17" id="tag_20_38_13_17"></a>List Command</h5> 601 <dl compact> 602 <dd></dd> 603 <dt><i>Synopsis</i>:</dt> 604 <dd> 605 <p class="tent"></p> 606 <pre> 607 <tt>(.,.)l 608 </tt></pre></dd> 609 </dl> 610 <p class="tent">The <b>l</b> command shall write to standard output the addressed lines in a visually unambiguous form. The 611 characters listed in XBD <a href="../basedefs/V1_chap05.html#tagtcjh_2"><i>Escape Sequences and Associated Actions</i></a> 612 (<tt>'\\'</tt>, <tt>'\a'</tt>, <tt>'\b'</tt>, <tt>'\f'</tt>, <tt>'\r'</tt>, <tt>'\t'</tt>, <tt>'\v'</tt>) shall be written as the 613 corresponding escape sequence; the <tt>'\n'</tt> in that table is not applicable. Non-printable characters not in the table shall 614 be written as one three-digit octal number (with a preceding <backslash> character) for each byte in the character (most 615 significant byte first).</p> 616 <p class="tent">Long lines shall be folded, with the point of folding indicated by <newline> preceded by a <backslash>; 617 the length at which folding occurs is unspecified, but should be appropriate for the output device. The end of each line shall be 618 marked with a <tt>'$'</tt>, and <tt>'$'</tt> characters within the text shall be written with a preceding <backslash>. An 619 <b>l</b> command can be appended to any other command other than <b>e</b>, <b>E</b>, <b>f</b>, <b>q</b>, <b>Q</b>, <b>r</b>, 620 <b>w</b>, or <b>!</b>. The current line number shall be set to the address of the last line written.</p> 621 <h5><a name="tag_20_38_13_18" id="tag_20_38_13_18"></a>Move Command</h5> 622 <dl compact> 623 <dd></dd> 624 <dt><i>Synopsis</i>:</dt> 625 <dd> 626 <p class="tent"></p> 627 <pre> 628 <tt>(.,.)m</tt><i>address</i><tt> 629 </tt></pre></dd> 630 </dl> 631 <p class="tent">The <b>m</b> command shall reposition the addressed lines after the line addressed by <i>address</i>. Address 0 632 shall be valid for <i>address</i> and cause the addressed lines to be moved to the beginning of the buffer. It shall be an error if 633 address <i>address</i> falls within the range of moved lines. The current line number shall be set to the address of the last line 634 moved.</p> 635 <h5><a name="tag_20_38_13_19" id="tag_20_38_13_19"></a>Number Command</h5> 636 <dl compact> 637 <dd></dd> 638 <dt><i>Synopsis</i>:</dt> 639 <dd> 640 <p class="tent"></p> 641 <pre> 642 <tt>(.,.)n 643 </tt></pre></dd> 644 </dl> 645 <p class="tent">The <b>n</b> command shall write to standard output the addressed lines, preceding each line by its line number and 646 a <tab>; the current line number shall be set to the address of the last line written. The <b>n</b> command can be appended 647 to any command other than <b>e</b>, <b>E</b>, <b>f</b>, <b>q</b>, <b>Q</b>, <b>r</b>, <b>w</b>, or <b>!</b>.</p> 648 <h5><a name="tag_20_38_13_20" id="tag_20_38_13_20"></a>Print Command</h5> 649 <dl compact> 650 <dd></dd> 651 <dt><i>Synopsis</i>:</dt> 652 <dd> 653 <p class="tent"></p> 654 <pre> 655 <tt>(.,.)p 656 </tt></pre></dd> 657 </dl> 658 <p class="tent">The <b>p</b> command shall write to standard output the addressed lines; the current line number shall be set to 659 the address of the last line written. The <b>p</b> command can be appended to any command other than <b>e</b>, <b>E</b>, <b>f</b>, 660 <b>q</b>, <b>Q</b>, <b>r</b>, <b>w</b>, or <b>!</b>.</p> 661 <h5><a name="tag_20_38_13_21" id="tag_20_38_13_21"></a>Prompt Command</h5> 662 <dl compact> 663 <dd></dd> 664 <dt><i>Synopsis</i>:</dt> 665 <dd> 666 <p class="tent"></p> 667 <pre> 668 <tt>P 669 </tt></pre></dd> 670 </dl> 671 <p class="tent">The <b>P</b> command shall cause <i>ed</i> to prompt with an <asterisk> (<tt>'*'</tt>) (or <i>string</i>, if 672 <b>-p</b> is specified) for all subsequent commands. The <b>P</b> command alternatively shall turn this mode on and off; it shall 673 be initially on if the <b>-p</b> option is specified; otherwise, off. The current line number shall be unchanged.</p> 674 <h5><a name="tag_20_38_13_22" id="tag_20_38_13_22"></a>Quit Command</h5> 675 <dl compact> 676 <dd></dd> 677 <dt><i>Synopsis</i>:</dt> 678 <dd> 679 <p class="tent"></p> 680 <pre> 681 <tt>q 682 </tt></pre></dd> 683 </dl> 684 <p class="tent">The <b>q</b> command shall cause <i>ed</i> to exit. If the buffer change flag is currently set to <b>changed</b>, 685 the user shall be warned, as described previously.</p> 686 <h5><a name="tag_20_38_13_23" id="tag_20_38_13_23"></a>Quit Without Checking Command</h5> 687 <dl compact> 688 <dd></dd> 689 <dt><i>Synopsis</i>:</dt> 690 <dd> 691 <p class="tent"></p> 692 <pre> 693 <tt>Q 694 </tt></pre></dd> 695 </dl> 696 <p class="tent">The <b>Q</b> command shall cause <i>ed</i> to exit without checking the current state of the buffer change 697 flag.</p> 698 <h5><a name="tag_20_38_13_24" id="tag_20_38_13_24"></a>Read Command</h5> 699 <dl compact> 700 <dd></dd> 701 <dt><i>Synopsis</i>:</dt> 702 <dd> 703 <p class="tent"></p> 704 <pre> 705 <tt>($)r</tt><b> [</b><i>file</i><b>]</b><tt> 706 </tt></pre></dd> 707 </dl> 708 <p class="tent">The <b>r</b> command shall read in the file named by the pathname <i>file</i> and append it after the addressed 709 line. If no <i>file</i> argument is given, the currently remembered pathname, if any, shall be used (see the <b>e</b> and <b>f</b> 710 commands). The currently remembered pathname shall not be changed unless there is no remembered pathname. Address 0 shall be valid 711 for <b>r</b> and shall cause the file to be read at the beginning of the buffer. If the read is successful, and <b>-s</b> was not 712 specified, the number of bytes read shall be written to standard output in the following format:</p> 713 <pre> 714 <tt>"%d\n", <</tt><i>number of bytes read</i><tt>> 715 </tt></pre> 716 <p class="tent">The current line number shall be set to the address of the last line read in. If <i>file</i> is replaced by 717 <tt>'!'</tt>, 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 718 shall not be remembered as the current pathname.</p> 719 <p class="tent">If the number of bytes read is 0 it is unspecified whether the buffer change flag is set to <b>changed</b> or left 720 unaltered.</p> 721 <h5><a name="tag_20_38_13_25" id="tag_20_38_13_25"></a>Substitute Command</h5> 722 <dl compact> 723 <dd></dd> 724 <dt><i>Synopsis</i>:</dt> 725 <dd> 726 <p class="tent"></p> 727 <pre> 728 <tt>(.,.)s/</tt><i>RE</i><tt>/</tt><i>replacement</i><tt>/</tt><i>flags</i><tt> 729 </tt></pre></dd> 730 </dl> 731 <p class="tent">The <b>s</b> command shall search each addressed line for an occurrence of the specified RE and replace either the 732 first or all (non-overlapped) matched strings with the <i>replacement</i>; see the following description of the <b>g</b> suffix. 733 Any character other than <backslash>, <space>, or <newline> can be used instead of a <slash> to delimit the 734 RE and the replacement. Within the RE, in certain circumstances the RE delimiter can be used as a literal character; see <a href= 735 "#tag_20_38_13_01">Regular Expressions in ed</a> . Within the replacement, the delimiter shall not terminate the replacement if it 736 is the second character of an escape sequence (see XBD <a href="../basedefs/V1_chap09.html#tag_09_01"><i>9.1 Regular Expression 737 Definitions</i></a> ) and the escaped delimiter shall be treated as that literal character in the replacement (losing any special 738 meaning it would have had if it was not used as the delimiter and was not escaped). It shall be an error if the substitution fails 739 on every addressed line. The current line shall be set to the address of the last line on which a substitution occurred.</p> 740 <p class="tent">An unescaped <ampersand> (<tt>'&'</tt>) appearing in the replacement shall be replaced by the string 741 matching the RE on the current line. As a more general feature, the characters <tt>'\n'</tt>, where the <backslash> is 742 unescaped and <i>n</i> is a digit, shall be replaced by the text matched by the corresponding back-reference expression. If the 743 corresponding back-reference expression does not match, then the characters <tt>'\n'</tt> shall be replaced by the empty string. 744 When the character <tt>'%'</tt> is the only character in <i>replacement</i>, the <i>replacement</i> used in the most recent 745 substitute command shall be used as <i>replacement</i> in the current substitute command; if there was no previous substitute 746 command, the use of <tt>'%'</tt> in this manner shall be an error. The <tt>'%'</tt> shall lose its special meaning when it is in a 747 replacement string of more than one character or is escaped. It is unspecified what special meaning is given to any character other 748 than <backslash>, <tt>'&'</tt>, <tt>'%'</tt>, or digits.</p> 749 <p class="tent">A line can be split by substituting a <newline> into it. The application shall ensure it escapes the 750 <newline> in the <i>replacement</i> by preceding it by <backslash>. Such substitution cannot be done as part of a 751 <b>g</b> or <b>v</b> <i>command list</i>. The current line number shall be set to the address of the last line on which a 752 substitution is performed. If no substitution is performed, the current line number shall be unchanged. If a line is split, a 753 substitution shall be considered to have been performed on each of the new lines for the purpose of determining the new current 754 line number. A substitution shall be considered to have been performed even if the replacement string is identical to the string 755 that it replaces.</p> 756 <p class="tent">The application shall ensure that the value of <i>flags</i> is zero or more of:</p> 757 <dl compact> 758 <dd></dd> 759 <dt><i>count</i></dt> 760 <dd>Substitute for the <i>count</i>th occurrence only of the RE found on each addressed line.</dd> 761 <dt><b>g</b></dt> 762 <dd>Globally substitute for all non-overlapping instances of the RE rather than just the first one. If both <b>g</b> and 763 <i>count</i> are specified, the results are unspecified.</dd> 764 <dt><b>l</b></dt> 765 <dd>Write to standard output the final line in which a substitution was made. The line shall be written in the format specified for 766 the <b>l</b> command.</dd> 767 <dt><b>n</b></dt> 768 <dd>Write to standard output the final line in which a substitution was made. The line shall be written in the format specified for 769 the <b>n</b> command.</dd> 770 <dt><b>p</b></dt> 771 <dd>Write to standard output the final line in which a substitution was made. The line shall be written in the format specified for 772 the <b>p</b> command.</dd> 773 </dl> 774 <h5><a name="tag_20_38_13_26" id="tag_20_38_13_26"></a>Copy Command</h5> 775 <dl compact> 776 <dd></dd> 777 <dt><i>Synopsis</i>:</dt> 778 <dd> 779 <p class="tent"></p> 780 <pre> 781 <tt>(.,.)t</tt><i>address</i><tt> 782 </tt></pre></dd> 783 </dl> 784 <p class="tent">The <b>t</b> command shall be equivalent to the <b>m</b> command, except that a copy of the addressed lines shall 785 be placed after address <i>address</i> (which can be 0); the current line number shall be set to the address of the last line 786 added.</p> 787 <h5><a name="tag_20_38_13_27" id="tag_20_38_13_27"></a>Undo Command</h5> 788 <dl compact> 789 <dd></dd> 790 <dt><i>Synopsis</i>:</dt> 791 <dd> 792 <p class="tent"></p> 793 <pre> 794 <tt>u 795 </tt></pre></dd> 796 </dl> 797 <p class="tent">The <b>u</b> command shall nullify the effect of the most recent command that modified anything in the buffer, 798 namely the most recent <b>a</b>, <b>c</b>, <b>d</b>, <b>g</b>, <b>i</b>, <b>j</b>, <b>m</b>, <b>r</b>, <b>s</b>, <b>t</b>, 799 <b>u</b>, <b>v</b>, <b>G</b>, or <b>V</b> command. All changes made to the buffer by a <b>g</b>, <b>G</b>, <b>v</b>, or <b>V</b> 800 global command shall be undone as a single change; if no changes were made by the global command (such as with 801 <b>g</b>/RE/<b>p</b>), the <b>u</b> command shall have no effect. The current line number shall be set to the value it had 802 immediately before the command being undone started.</p> 803 <h5><a name="tag_20_38_13_28" id="tag_20_38_13_28"></a>Global Non-Matched Command</h5> 804 <dl compact> 805 <dd></dd> 806 <dt><i>Synopsis</i>:</dt> 807 <dd> 808 <p class="tent"></p> 809 <pre> 810 <tt>(1,$)v/</tt><i>RE</i><tt>/</tt><i>command list</i><tt> 811 </tt></pre></dd> 812 </dl> 813 <p class="tent">This command shall be equivalent to the global command <b>g</b> except that the lines that are marked during the 814 first step shall be those for which the line excluding the terminating <newline> does not match the RE.</p> 815 <h5><a name="tag_20_38_13_29" id="tag_20_38_13_29"></a>Interactive Global Not-Matched Command</h5> 816 <dl compact> 817 <dd></dd> 818 <dt><i>Synopsis</i>:</dt> 819 <dd> 820 <p class="tent"></p> 821 <pre> 822 <tt>(1,$)V/</tt><i>RE</i><tt>/ 823 </tt></pre></dd> 824 </dl> 825 <p class="tent">This command shall be equivalent to the interactive global command <b>G</b> except that the lines that are marked 826 during the first step shall be those for which the line excluding the terminating <newline> does not match the RE.</p> 827 <h5><a name="tag_20_38_13_30" id="tag_20_38_13_30"></a>Write Command</h5> 828 <dl compact> 829 <dd></dd> 830 <dt><i>Synopsis</i>:</dt> 831 <dd> 832 <p class="tent"></p> 833 <pre> 834 <tt>(1,$)w</tt><b> [</b><i>file</i><b>] 835 </b></pre></dd> 836 </dl> 837 <p class="tent">The <b>w</b> command shall write the addressed lines into the file named by the pathname <i>file</i>. The command 838 shall create the file, if it does not exist, or shall replace the contents of the existing file. The currently remembered pathname 839 shall not be changed unless there is no remembered pathname. If no pathname is given, the currently remembered pathname, if any, 840 shall be used (see the <b>e</b> and <b>f</b> commands); the current line number shall be unchanged. If the command is successful, 841 the number of bytes written shall be written to standard output, unless the <b>-s</b> option was specified, in the following 842 format:</p> 843 <pre> 844 <tt>"%d\n", <</tt><i>number of bytes written</i><tt>> 845 </tt></pre> 846 <p class="tent">If <i>file</i> begins with <tt>'!'</tt>, the rest of the line shall be taken to be a shell command line whose 847 standard input shall be the addressed lines. Such a shell command line shall not be remembered as the current pathname. This usage 848 of the <b>w</b> command with <tt>'!'</tt> shall not alter the buffer change flag; thus, this alone shall not prevent the warning to 849 the user if an attempt is made to destroy the editor buffer via the <b>e</b> or <b>q</b> commands.</p> 850 <h5><a name="tag_20_38_13_31" id="tag_20_38_13_31"></a>Line Number Command</h5> 851 <dl compact> 852 <dd></dd> 853 <dt><i>Synopsis</i>:</dt> 854 <dd> 855 <p class="tent"></p> 856 <pre> 857 <tt>($)= 858 </tt></pre></dd> 859 </dl> 860 <p class="tent">The line number of the addressed line shall be written to standard output in the following format:</p> 861 <pre> 862 <tt>"%d\n", <</tt><i>line number</i><tt>> 863 </tt></pre> 864 <p class="tent">The current line number shall be unchanged by this command.</p> 865 <h5><a name="tag_20_38_13_32" id="tag_20_38_13_32"></a>Shell Escape Command</h5> 866 <dl compact> 867 <dd></dd> 868 <dt><i>Synopsis</i>:</dt> 869 <dd> 870 <p class="tent"></p> 871 <pre> 872 <tt>!</tt><i>command</i><tt> 873 </tt></pre></dd> 874 </dl> 875 <p class="tent">The remainder of the line after the <tt>'!'</tt> shall be sent to the command interpreter to be interpreted as a 876 shell command line. Within the text of that shell command line, the unescaped character <tt>'%'</tt> shall be replaced with the 877 remembered pathname; if a <tt>'!'</tt> appears as the first character of the command, it shall be replaced with the text of the 878 previous shell command executed via <tt>'!'</tt>. Thus, <tt>"!!"</tt> shall repeat the previous !<i>command</i>. If any 879 replacements of <tt>'%'</tt> or <tt>'!'</tt> are performed, the modified line shall be written to the standard output before 880 <i>command</i> is executed. The <b>!</b> command shall write:</p> 881 <pre> 882 <tt>"!\n" 883 </tt></pre> 884 <p class="tent">to standard output upon completion, unless the <b>-s</b> option is specified. The current line number shall be 885 unchanged.</p> 886 <h5><a name="tag_20_38_13_33" id="tag_20_38_13_33"></a>Null Command</h5> 887 <dl compact> 888 <dd></dd> 889 <dt><i>Synopsis</i>:</dt> 890 <dd> 891 <p class="tent"></p> 892 <pre> 893 <tt>(.+1) 894 </tt></pre></dd> 895 </dl> 896 <p class="tent">An address alone on a line shall cause the addressed line to be written. A <newline> alone shall be 897 equivalent to <tt>"+1p"</tt>. The current line number shall be set to the address of the written line.</p> 898 </blockquote> 899 <h4 class="mansect"><a name="tag_20_38_14" id="tag_20_38_14"></a>EXIT STATUS</h4> 900 <blockquote> 901 <p>The following exit values shall be returned:</p> 902 <dl compact> 903 <dd></dd> 904 <dt> 0</dt> 905 <dd>Successful completion without any file or command errors.</dd> 906 <dt>>0</dt> 907 <dd>An error occurred.</dd> 908 </dl> 909 </blockquote> 910 <h4 class="mansect"><a name="tag_20_38_15" id="tag_20_38_15"></a>CONSEQUENCES OF ERRORS</h4> 911 <blockquote> 912 <p>When an error in the input script is encountered, or when an error is detected that is a consequence of the data (not) present 913 in the file or due to an external condition such as a read or write error:</p> 914 <ul> 915 <li class="tent">If the standard input is a terminal device file, all input shall be flushed, and a new command read.</li> 916 <li class="tent">If the standard input is not a terminal device file, <i>ed</i> shall behave as described under CONSEQUENCES OF 917 ERRORS in <a href="../utilities/V3_chap01.html#tag_18_04"><i>1.4 Utility Description Defaults</i></a> .</li> 918 </ul> 919 </blockquote> 920 <hr> 921 <div class="box"><em>The following sections are informative.</em></div> 922 <h4 class="mansect"><a name="tag_20_38_16" id="tag_20_38_16"></a>APPLICATION USAGE</h4> 923 <blockquote> 924 <p>Because of the extremely terse nature of the default error messages, the prudent script writer begins the <i>ed</i> input 925 commands with an <b>H</b> command, so that if any errors do occur at least some clue as to the cause is made available.</p> 926 <p class="tent">In earlier versions of this standard, an obsolescent <b>-</b> option was described. This is no longer specified. 927 Applications should use the <b>-s</b> option. Using <b>-</b> as a <i>file</i> operand now produces unspecified results. This allows 928 implementations to continue to support the former required behavior.</p> 929 </blockquote> 930 <h4 class="mansect"><a name="tag_20_38_17" id="tag_20_38_17"></a>EXAMPLES</h4> 931 <blockquote> 932 <p>None.</p> 933 </blockquote> 934 <h4 class="mansect"><a name="tag_20_38_18" id="tag_20_38_18"></a>RATIONALE</h4> 935 <blockquote> 936 <p>The initial description of this utility was adapted from the SVID. It contains some features not found in Version 7 or 937 BSD-derived systems. Some of the differences between the POSIX and BSD <i>ed</i> utilities include, but need not be limited to:</p> 938 <ul> 939 <li class="tent">The BSD <b>-</b> option does not suppress the <tt>'!'</tt> prompt after a <b>!</b> command.</li> 940 <li class="tent">BSD does not support the special meanings of the <tt>'%'</tt> and <tt>'!'</tt> characters within a <b>!</b> 941 command.</li> 942 <li class="tent">BSD does not support the <i>addresses</i> <tt>';'</tt> and <tt>','</tt>.</li> 943 <li class="tent">BSD allows the command/suffix pairs <b>pp</b>, <b>ll</b>, and so on, which are unspecified in this volume of 944 POSIX.1-2024.</li> 945 <li class="tent">BSD does not support the <tt>'!'</tt> character part of the <b>e</b>, <b>r</b>, or <b>w</b> commands.</li> 946 <li class="tent">A failed <b>g</b> command in BSD sets the line number to the last line searched if there are no matches.</li> 947 <li class="tent">BSD does not default the <i>command list</i> to the <b>p</b> command.</li> 948 <li class="tent">BSD does not support the <b>G</b>, <b>h</b>, <b>H</b>, <b>n</b>, or <b>V</b> commands.</li> 949 <li class="tent">On BSD, if there is no inserted text, the insert command changes the current line to the referenced line -1; that 950 is, the line before the specified line.</li> 951 <li class="tent">On BSD, the <b>j</b> command with only a single address changes the current line to that address.</li> 952 <li class="tent">BSD does not support the <b>P</b> command; moreover, in BSD it is synonymous with the <b>p</b> command.</li> 953 <li class="tent">BSD does not support the <i>undo</i> of the commands <b>j</b>, <b>m</b>, <b>r</b>, <b>s</b>, or <b>t</b>.</li> 954 <li class="tent">The Version 7 <i>ed</i> command <b>W</b>, and the BSD <i>ed</i> commands <b>W</b>, <b>wq</b>, and <b>z</b> are not 955 present in this volume of POSIX.1-2024.</li> 956 </ul> 957 <p class="tent">The <b>-s</b> option was added to allow the functionality of the removed <b>-</b> option in a manner compatible 958 with the Utility Syntax Guidelines.</p> 959 <p class="tent">In early proposals there was a limit, {ED_FILE_MAX}, that described the historical limitations of some <i>ed</i> 960 utilities in their handling of large files; some of these have had problems with files larger than 100000 bytes. It was this 961 limitation that prompted much of the desire to include a <a href="../utilities/split.html"><i>split</i></a> command in this volume 962 of POSIX.1-2024. Since this limit was removed, this volume of POSIX.1-2024 requires that implementations document the file size 963 limits imposed by <i>ed</i> in the conformance document. The limit {ED_LINE_MAX} was also removed; therefore, the global limit 964 {LINE_MAX} is used for input and output lines.</p> 965 <p class="tent">The manner in which the <b>l</b> command writes non-printable characters was changed to avoid the historical 966 backspace-overstrike method. On video display terminals, the overstrike is ambiguous because most terminals simply replace 967 overstruck characters, making the <b>l</b> format not useful for its intended purpose of unambiguously understanding the content of 968 the line. The historical <backslash>-escapes were also ambiguous. (The string <tt>"a\0011"</tt> could represent a line 969 containing those six characters or a line containing the three characters <tt>'a'</tt>, a byte with a binary value of 1, and a 1.) 970 In the format required here, a <backslash> appearing in the line is written as <tt>"\\"</tt> so that the output is truly 971 unambiguous. The method of marking the ends of lines was adopted from the <a href="../utilities/ex.html"><i>ex</i></a> editor and 972 is required for any line ending in <space> characters; the <tt>'$'</tt> is placed on all lines so that a real <tt>'$'</tt> at 973 the end of a line cannot be misinterpreted.</p> 974 <p class="tent">Earlier versions of this standard allowed for implementations with bytes other than eight bits, but this has been 975 modified in this version.</p> 976 <p class="tent">The description of how a NUL is written was removed. The NUL character cannot be in text files, and this volume of 977 POSIX.1-2024 should not dictate behavior in the case of undefined, erroneous input.</p> 978 <p class="tent">Unlike some of the other editing utilities, the filenames accepted by the <b>E</b>, <b>e</b>, <b>R</b>, and 979 <b>r</b> commands are not patterns.</p> 980 <p class="tent">Early proposals stated that the <b>-p</b> option worked only when standard input was associated with a terminal 981 device. This has been changed to conform to historical implementations, thereby allowing applications to interpose themselves 982 between a user and the <i>ed</i> utility.</p> 983 <p class="tent">The form of the substitute command that uses the <b>n</b> suffix was limited in some historical documentation 984 (where this was described incorrectly as "backreferencing"). This limit has been omitted because there is no reason why an editor 985 processing lines of {LINE_MAX} length should have this restriction. The command <b>s/x/X/2047</b> should be able to substitute the 986 2047th occurrence of <tt>'x'</tt> on a line.</p> 987 <p class="tent">The use of printing commands with printing suffixes (such as <b>pn</b>, <b>lp</b>, and so on) was made unspecified 988 because BSD-based systems allow this, whereas System V does not.</p> 989 <p class="tent">Some BSD-based systems exit immediately upon receipt of end-of-file if all of the lines in the file have been 990 deleted. Since this volume of POSIX.1-2024 refers to the <b>q</b> command in this instance, such behavior is not allowed.</p> 991 <p class="tent">Some historical implementations returned exit status zero even if command errors had occurred; this is not allowed 992 by this volume of POSIX.1-2024.</p> 993 <p class="tent">Some historical implementations contained a bug that allowed a single <period> to be entered in input mode as 994 <backslash> <period> <newline>. This is not allowed by <i>ed</i> because there is no description of escaping any 995 of the characters in input mode; <backslash> characters are entered into the buffer exactly as typed. The typical method of 996 entering a single <period> has been to precede it with another character and then use the substitute command to delete that 997 character.</p> 998 <p class="tent">It is difficult under some modes of some versions of historical operating system terminal drivers to distinguish 999 between an end-of-file condition and terminal disconnect. POSIX.1-2024 does not require implementations to distinguish between the 1000 two situations, which permits historical implementations of the <i>ed</i> utility on historical platforms to conform. 1001 Implementations are encouraged to distinguish between the two, if possible, and take appropriate action on terminal disconnect.</p> 1002 <p class="tent">Historically, <i>ed</i> accepted a zero address for the <b>a</b> and <b>r</b> commands in order to insert text at 1003 the start of the edit buffer. When the buffer was empty the command <b>.=</b> returned zero. POSIX.1-2024 requires conformance to 1004 historical practice.</p> 1005 <p class="tent">For consistency with the <b>a</b> and <b>r</b> commands and better user functionality, the <b>i</b> command also 1006 accepts an address of 0. However, it is unspecified if <tt>0i</tt> is treated as <tt>1i</tt> (which will fail if the buffer is 1007 empty), or means insert at the beginning of the buffer (which will succeed even if the buffer is empty). Earlier versions of this 1008 standard required address 0 for the <b>c</b> command to be treated as 1 also, but this requirement has been removed, though 1009 implementations are permitted to do this as an extension.</p> 1010 <p class="tent">All of the following are valid addresses:</p> 1011 <dl compact> 1012 <dd></dd> 1013 <dt><tt>+++</tt></dt> 1014 <dd>Three lines after the current line.</dd> 1015 <dt><tt>/</tt><i>pattern</i><tt>/-</tt></dt> 1016 <dd>One line before the next occurrence of pattern.</dd> 1017 <dt><tt>-2</tt></dt> 1018 <dd>Two lines before the current line.</dd> 1019 <dt><tt>3 ---- 2</tt></dt> 1020 <dd>Line one (note the intermediate negative address).</dd> 1021 <dt><tt>1 2 3</tt></dt> 1022 <dd>Line six.</dd> 1023 </dl> 1024 <p class="tent">More than the maximum number of accepted addresses can be provided to commands taking addresses; for example, 1025 <tt>"1,2,3,4,5p"</tt> prints lines 4 and 5, because two is the maximum number of addresses accepted by the <b>print</b> command. 1026 This, in combination with the <semicolon> delimiter, permits users to create commands based on ordered patterns in the file. 1027 For example, the command <tt>"3;/foo/;+2p"</tt> will display the first line after line 3 that contains the pattern <i>foo</i>, plus 1028 the next two lines. Note that the address <tt>"3;"</tt> must still be evaluated before being discarded, because the search origin 1029 for the <tt>"/foo/"</tt> address depends on this.</p> 1030 <p class="tent">Historically, <i>ed</i> disallowed address chains, as discussed above, consisting solely of <comma> or 1031 <semicolon> separators; for example, <tt>",,,"</tt> or <tt>";;;"</tt> were considered an error. For consistency of address 1032 specification, this restriction is removed. The following table lists some of the address forms now possible:</p> 1033 <center> 1034 <table border="1" cellpadding="3" align="center"> 1035 <tr valign="top"> 1036 <th align="center"> 1037 <p class="tent"><b>Address</b></p> 1038 </th> 1039 <th align="center"> 1040 <p class="tent"><b>Addr1</b></p> 1041 </th> 1042 <th align="center"> 1043 <p class="tent"><b>Addr2</b></p> 1044 </th> 1045 <th align="center"> 1046 <p class="tent"><b>Status</b></p> 1047 </th> 1048 <th align="center"> 1049 <p class="tent"><b>Comment</b></p> 1050 </th> 1051 </tr> 1052 <tr valign="top"> 1053 <td align="left"> 1054 <p class="tent">7,</p> 1055 </td> 1056 <td align="left"> 1057 <p class="tent">7</p> 1058 </td> 1059 <td align="left"> 1060 <p class="tent">7</p> 1061 </td> 1062 <td align="left"> 1063 <p class="tent">Historical</p> 1064 </td> 1065 <td align="left"> 1066 <p class="tent"> </p> 1067 </td> 1068 </tr> 1069 <tr valign="top"> 1070 <td align="left"> 1071 <p class="tent">7,5,</p> 1072 </td> 1073 <td align="left"> 1074 <p class="tent">5</p> 1075 </td> 1076 <td align="left"> 1077 <p class="tent">5</p> 1078 </td> 1079 <td align="left"> 1080 <p class="tent">Historical</p> 1081 </td> 1082 <td align="left"> 1083 <p class="tent"> </p> 1084 </td> 1085 </tr> 1086 <tr valign="top"> 1087 <td align="left"> 1088 <p class="tent">7,5,9</p> 1089 </td> 1090 <td align="left"> 1091 <p class="tent">5</p> 1092 </td> 1093 <td align="left"> 1094 <p class="tent">9</p> 1095 </td> 1096 <td align="left"> 1097 <p class="tent">Historical</p> 1098 </td> 1099 <td align="left"> 1100 <p class="tent"> </p> 1101 </td> 1102 </tr> 1103 <tr valign="top"> 1104 <td align="left"> 1105 <p class="tent">7,9</p> 1106 </td> 1107 <td align="left"> 1108 <p class="tent">7</p> 1109 </td> 1110 <td align="left"> 1111 <p class="tent">9</p> 1112 </td> 1113 <td align="left"> 1114 <p class="tent">Historical</p> 1115 </td> 1116 <td align="left"> 1117 <p class="tent"> </p> 1118 </td> 1119 </tr> 1120 <tr valign="top"> 1121 <td align="left"> 1122 <p class="tent">7,+</p> 1123 </td> 1124 <td align="left"> 1125 <p class="tent">7</p> 1126 </td> 1127 <td align="left"> 1128 <p class="tent">.+</p> 1129 </td> 1130 <td align="left"> 1131 <p class="tent">Historical</p> 1132 </td> 1133 <td align="left"> 1134 <p class="tent"> </p> 1135 </td> 1136 </tr> 1137 <tr valign="top"> 1138 <td align="left"> 1139 <p class="tent">,</p> 1140 </td> 1141 <td align="left"> 1142 <p class="tent">1</p> 1143 </td> 1144 <td align="left"> 1145 <p class="tent">$</p> 1146 </td> 1147 <td align="left"> 1148 <p class="tent">Historical</p> 1149 </td> 1150 <td align="left"> 1151 <p class="tent"> </p> 1152 </td> 1153 </tr> 1154 <tr valign="top"> 1155 <td align="left"> 1156 <p class="tent">,7</p> 1157 </td> 1158 <td align="left"> 1159 <p class="tent">1</p> 1160 </td> 1161 <td align="left"> 1162 <p class="tent">7</p> 1163 </td> 1164 <td align="left"> 1165 <p class="tent">Extension</p> 1166 </td> 1167 <td align="left"> 1168 <p class="tent"> </p> 1169 </td> 1170 </tr> 1171 <tr valign="top"> 1172 <td align="left"> 1173 <p class="tent">,,</p> 1174 </td> 1175 <td align="left"> 1176 <p class="tent">$</p> 1177 </td> 1178 <td align="left"> 1179 <p class="tent">$</p> 1180 </td> 1181 <td align="left"> 1182 <p class="tent">Extension</p> 1183 </td> 1184 <td align="left"> 1185 <p class="tent"> </p> 1186 </td> 1187 </tr> 1188 <tr valign="top"> 1189 <td align="left"> 1190 <p class="tent">,;</p> 1191 </td> 1192 <td align="left"> 1193 <p class="tent">$</p> 1194 </td> 1195 <td align="left"> 1196 <p class="tent">$</p> 1197 </td> 1198 <td align="left"> 1199 <p class="tent">Extension</p> 1200 </td> 1201 <td align="left"> 1202 <p class="tent"> </p> 1203 </td> 1204 </tr> 1205 <tr valign="top"> 1206 <td align="left"> 1207 <p class="tent">7;</p> 1208 </td> 1209 <td align="left"> 1210 <p class="tent">7</p> 1211 </td> 1212 <td align="left"> 1213 <p class="tent">7</p> 1214 </td> 1215 <td align="left"> 1216 <p class="tent">Historical</p> 1217 </td> 1218 <td align="left"> 1219 <p class="tent"> </p> 1220 </td> 1221 </tr> 1222 <tr valign="top"> 1223 <td align="left"> 1224 <p class="tent">7;5;</p> 1225 </td> 1226 <td align="left"> 1227 <p class="tent">5</p> 1228 </td> 1229 <td align="left"> 1230 <p class="tent">5</p> 1231 </td> 1232 <td align="left"> 1233 <p class="tent">Historical</p> 1234 </td> 1235 <td align="left"> 1236 <p class="tent"> </p> 1237 </td> 1238 </tr> 1239 <tr valign="top"> 1240 <td align="left"> 1241 <p class="tent">7;5;9</p> 1242 </td> 1243 <td align="left"> 1244 <p class="tent">5</p> 1245 </td> 1246 <td align="left"> 1247 <p class="tent">9</p> 1248 </td> 1249 <td align="left"> 1250 <p class="tent">Historical</p> 1251 </td> 1252 <td align="left"> 1253 <p class="tent"> </p> 1254 </td> 1255 </tr> 1256 <tr valign="top"> 1257 <td align="left"> 1258 <p class="tent">7;5,9</p> 1259 </td> 1260 <td align="left"> 1261 <p class="tent">5</p> 1262 </td> 1263 <td align="left"> 1264 <p class="tent">9</p> 1265 </td> 1266 <td align="left"> 1267 <p class="tent">Historical</p> 1268 </td> 1269 <td align="left"> 1270 <p class="tent"> </p> 1271 </td> 1272 </tr> 1273 <tr valign="top"> 1274 <td align="left"> 1275 <p class="tent">7;$;4</p> 1276 </td> 1277 <td align="left"> 1278 <p class="tent">$</p> 1279 </td> 1280 <td align="left"> 1281 <p class="tent">4</p> 1282 </td> 1283 <td align="left"> 1284 <p class="tent">Historical</p> 1285 </td> 1286 <td align="left"> 1287 <p class="tent">Valid, but erroneous.</p> 1288 </td> 1289 </tr> 1290 <tr valign="top"> 1291 <td align="left"> 1292 <p class="tent">7;9</p> 1293 </td> 1294 <td align="left"> 1295 <p class="tent">7</p> 1296 </td> 1297 <td align="left"> 1298 <p class="tent">9</p> 1299 </td> 1300 <td align="left"> 1301 <p class="tent">Historical</p> 1302 </td> 1303 <td align="left"> 1304 <p class="tent"> </p> 1305 </td> 1306 </tr> 1307 <tr valign="top"> 1308 <td align="left"> 1309 <p class="tent">7;+</p> 1310 </td> 1311 <td align="left"> 1312 <p class="tent">7</p> 1313 </td> 1314 <td align="left"> 1315 <p class="tent">8</p> 1316 </td> 1317 <td align="left"> 1318 <p class="tent">Historical</p> 1319 </td> 1320 <td align="left"> 1321 <p class="tent"> </p> 1322 </td> 1323 </tr> 1324 <tr valign="top"> 1325 <td align="left"> 1326 <p class="tent">;</p> 1327 </td> 1328 <td align="left"> 1329 <p class="tent">.</p> 1330 </td> 1331 <td align="left"> 1332 <p class="tent">$</p> 1333 </td> 1334 <td align="left"> 1335 <p class="tent">Historical</p> 1336 </td> 1337 <td align="left"> 1338 <p class="tent"> </p> 1339 </td> 1340 </tr> 1341 <tr valign="top"> 1342 <td align="left"> 1343 <p class="tent">;7</p> 1344 </td> 1345 <td align="left"> 1346 <p class="tent">.</p> 1347 </td> 1348 <td align="left"> 1349 <p class="tent">7</p> 1350 </td> 1351 <td align="left"> 1352 <p class="tent">Extension</p> 1353 </td> 1354 <td align="left"> 1355 <p class="tent"> </p> 1356 </td> 1357 </tr> 1358 <tr valign="top"> 1359 <td align="left"> 1360 <p class="tent">;;</p> 1361 </td> 1362 <td align="left"> 1363 <p class="tent">$</p> 1364 </td> 1365 <td align="left"> 1366 <p class="tent">$</p> 1367 </td> 1368 <td align="left"> 1369 <p class="tent">Extension</p> 1370 </td> 1371 <td align="left"> 1372 <p class="tent"> </p> 1373 </td> 1374 </tr> 1375 <tr valign="top"> 1376 <td align="left"> 1377 <p class="tent">;,</p> 1378 </td> 1379 <td align="left"> 1380 <p class="tent">$</p> 1381 </td> 1382 <td align="left"> 1383 <p class="tent">$</p> 1384 </td> 1385 <td align="left"> 1386 <p class="tent">Extension</p> 1387 </td> 1388 <td align="left"> 1389 <p class="tent"> </p> 1390 </td> 1391 </tr> 1392 </table> 1393 </center> 1394 <p class="tent">Historically, <i>ed</i> accepted the <tt>'^'</tt> character as an address, in which case it was identical to the 1395 <hyphen-minus> character. POSIX.1-2024 does not require or prohibit this behavior.</p> 1396 <p class="tent">Implementations are encouraged to set the buffer change flag to <b>changed-and-warned</b> when an <b>e</b> or 1397 <b>q</b> command warns that an attempt was made to destroy the editor buffer. Some existing implementations set it to 1398 <b>unchanged</b>, but this has the undesirable side-effect that a SIGHUP received after the warning is given does not write the 1399 buffer to <b>ed.hup</b>.</p> 1400 </blockquote> 1401 <h4 class="mansect"><a name="tag_20_38_19" id="tag_20_38_19"></a>FUTURE DIRECTIONS</h4> 1402 <blockquote> 1403 <p>If this utility is directed to create a new directory entry that contains any bytes that have the encoded value of a 1404 <newline> character, implementations are encouraged to treat this as an error. A future version of this standard may require 1405 implementations to treat this as an error.</p> 1406 <p class="tent">A future version of this standard may require that the buffer change flag is set to <b>changed-and-warned</b> when 1407 an <b>e</b> or <b>q</b> command warns that an attempt was made to destroy the editor buffer.</p> 1408 </blockquote> 1409 <h4 class="mansect"><a name="tag_20_38_20" id="tag_20_38_20"></a>SEE ALSO</h4> 1410 <blockquote> 1411 <p><a href="../utilities/V3_chap01.html#tag_18_04"><i>1.4 Utility Description Defaults</i></a> , <a href= 1412 "../utilities/ex.html#"><i>ex</i></a> , <a href="../utilities/sed.html#"><i>sed</i></a> , <a href= 1413 "../utilities/sh.html#"><i>sh</i></a> , <a href="../utilities/vi.html#"><i>vi</i></a></p> 1414 <p class="tent">XBD <a href="../basedefs/V1_chap05.html#tagtcjh_2"><i>Escape Sequences and Associated Actions</i></a> , <a href= 1415 "../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href="../basedefs/V1_chap09.html#tag_09_03"><i>9.3 1416 Basic Regular Expressions</i></a> , <a href="../basedefs/V1_chap11.html#tag_11"><i>11. General Terminal Interface</i></a> , 1417 <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p> 1418 </blockquote> 1419 <h4 class="mansect"><a name="tag_20_38_21" id="tag_20_38_21"></a>CHANGE HISTORY</h4> 1420 <blockquote> 1421 <p>First released in Issue 2.</p> 1422 </blockquote> 1423 <h4 class="mansect"><a name="tag_20_38_22" id="tag_20_38_22"></a>Issue 5</h4> 1424 <blockquote> 1425 <p>In the OPTIONS section, the meaning of <b>-s</b> and <b>-</b> is clarified.</p> 1426 <p class="tent">A second FUTURE DIRECTION is added.</p> 1427 </blockquote> 1428 <h4 class="mansect"><a name="tag_20_38_23" id="tag_20_38_23"></a>Issue 6</h4> 1429 <blockquote> 1430 <p>The obsolescent single-minus form is removed.</p> 1431 <p class="tent">A second APPLICATION USAGE note is added.</p> 1432 <p class="tent">The Open Group Corrigendum U025/2 is applied, correcting the description of the Edit section.</p> 1433 <p class="tent">The <i>ed</i> utility is updated to align with the IEEE P1003.2b draft standard. This includes addition of the 1434 treatment of the SIGQUIT signal, changes to <i>ed</i> addressing, and changes to processing when end-of-file is detected and when 1435 terminal disconnect is detected.</p> 1436 <p class="tent">The normative text is reworded to avoid use of the term "must" for application requirements.</p> 1437 <p class="tent">IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/22 is applied, adding the text: "Any line modified 1438 by the <i>command list</i> shall be unmarked." to the <b>G</b> command. This change corresponds to a similar change made to the 1439 <b>g</b> command in the first version of this standard.</p> 1440 <p class="tent">IEEE Std 1003.1-2001/Cor 2-2004, item XCU/TC2/D6/7 is applied, removing text describing behavior on 1441 systems with bytes consisting of more than eight bits.</p> 1442 </blockquote> 1443 <h4 class="mansect"><a name="tag_20_38_24" id="tag_20_38_24"></a>Issue 7</h4> 1444 <blockquote> 1445 <p>Austin Group Interpretation 1003.1-2001 #027 is applied, clarifying the behavior if an operand is <tt>'-'</tt>.</p> 1446 <p class="tent">Austin Group Interpretation 1003.1-2001 #036 is applied, clarifying the behavior for BREs.</p> 1447 <p class="tent">SD5-XCU-ERN-94 is applied, updating text in the EXTENDED DESCRIPTION where a terminal disconnect is detected (in 1448 Commands in <i>ed</i>).</p> 1449 <p class="tent">SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p> 1450 <p class="tent">SD5-XCU-ERN-135 is applied, removing some RATIONALE text that is no longer applicable.</p> 1451 <p class="tent">POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0090 [584], XCU/TC2-2008/0091 [584], and XCU/TC2-2008/0092 1452 [584] are applied.</p> 1453 </blockquote> 1454 <h4 class="mansect"><a name="tag_20_38_25" id="tag_20_38_25"></a>Issue 8</h4> 1455 <blockquote> 1456 <p>Austin Group Defect 251 is applied, encouraging implementations to disallow the creation of filenames containing any bytes that 1457 have the encoded value of a <newline> character.</p> 1458 <p class="tent">Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p> 1459 <p class="tent">Austin Group Defect 1130 is applied, removing the requirement for the <b>c</b> command to accept an address of 0 1460 and updating the information about address 0 in the RATIONALE section.</p> 1461 <p class="tent">Austin Group Defect 1131 is applied, changing the address 0 requirements for the <b>i</b> command.</p> 1462 <p class="tent">Austin Group Defect 1204 is applied, clarifying the behavior when a closing delimiter that would be the last 1463 character before a <newline> is omitted.</p> 1464 <p class="tent">Austin Group Defect 1281 is applied, moving some text in the description of the <b>s</b> command and changing it to 1465 use "shall".</p> 1466 <p class="tent">Austin Group Defect 1298 is applied, changing the CONSEQUENCES OF ERRORS section.</p> 1467 <p class="tent">Austin Group Defect 1308 is applied, changing the <b>Addr2</b> value for address <tt>7,+</tt> in the table of 1468 address forms in the RATIONALE section.</p> 1469 <p class="tent">Austin Group Defect 1311 is applied, changing "<i>join</i> command" to "<b>j</b> command" in the RATIONALE 1470 section.</p> 1471 <p class="tent">Austin Group Defect 1582 is applied, clarifying the behavior when an address is omitted between two address 1472 separators.</p> 1473 <p class="tent">Austin Group Defect 1607 is applied, clarifying the behavior when more than the maximum number of accepted 1474 addresses are provided to a command.</p> 1475 <p class="tent">Austin Group Defect 1662 is applied, clarifying requirements relating to delimiters in addresses and in <b>s</b> 1476 commands.</p> 1477 <p class="tent">Austin Group Defect 1786 is applied, clarifying the behavior when an <b>e</b> command names a file that does not 1478 exist, and clarifying how the <i>ed</i> utility keeps track of whether the buffer has been modified.</p> 1479 </blockquote> 1480 <div class="box"><em>End of informative text.</em></div> 1481 <hr> 1482 <p> </p> 1483 <a href="#top"><span class="topOfPage">return to top of page</span></a><br> 1484 <hr size="2" noshade> 1485 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br> 1486 POSIX™ is a Trademark of The IEEE.<br> 1487 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br> 1488 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href= 1489 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a> 1490 ]</font></center> 1491 <hr size="2" noshade> 1492 <div class="NAVHEADER"> 1493 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 1494 <tr class="nav"> 1495 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/echo.html" accesskey="P"><<< 1496 Previous</a></td> 1497 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 1498 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/env.html" accesskey="N">Next >>></a></td> 1499 </tr> 1500 </table> 1501 <hr align="left" width="100%"></div> 1502 </body> 1503 </html>