isposix

Un outil pour savoir si une commande est posix - retour accueil

git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |

echo.html (14886B)


      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>echo</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/du.html" accesskey="P">&lt;&lt;&lt;
     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/ed.html" accesskey="N">Next &gt;&gt;&gt;</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="echo" id="echo"></a> <a name="tag_20_37" id="tag_20_37"></a><!-- echo -->
     28 <h4 class="mansect"><a name="tag_20_37_01" id="tag_20_37_01"></a>NAME</h4>
     29 <blockquote>echo — write arguments to standard output</blockquote>
     30 <h4 class="mansect"><a name="tag_20_37_02" id="tag_20_37_02"></a>SYNOPSIS</h4>
     31 <blockquote class="synopsis">
     32 <p><code><tt>echo</tt> <b>[</b><i>string</i><tt>...</tt><b>]</b></code></p>
     33 </blockquote>
     34 <h4 class="mansect"><a name="tag_20_37_03" id="tag_20_37_03"></a>DESCRIPTION</h4>
     35 <blockquote>
     36 <p>The <i>echo</i> utility writes its arguments to standard output, followed by a &lt;newline&gt;. If there are no arguments, only
     37 the &lt;newline&gt; is written.</p>
     38 </blockquote>
     39 <h4 class="mansect"><a name="tag_20_37_04" id="tag_20_37_04"></a>OPTIONS</h4>
     40 <blockquote>
     41 <p>The <i>echo</i> utility shall not recognize the <tt>"--"</tt> argument in the manner specified by Guideline 10 of XBD <a href=
     42 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a> ; <tt>"--"</tt> shall be recognized as a string
     43 operand.</p>
     44 <p>Implementations shall not support any options.</p>
     45 </blockquote>
     46 <h4 class="mansect"><a name="tag_20_37_05" id="tag_20_37_05"></a>OPERANDS</h4>
     47 <blockquote>
     48 <p>The following operands shall be supported:</p>
     49 <dl compact>
     50 <dd></dd>
     51 <dt><i>string</i></dt>
     52 <dd>A string to be written to standard output. If the first operand consists of a <tt>'-'</tt> followed by one or more characters
     53 from the set {<tt>'e'</tt>, <tt>'E'</tt>, <tt>'n'</tt>}, or if any of the operands contain a &lt;backslash&gt; character, the
     54 results are implementation-defined.
     55 <p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
     56 On XSI-conformant systems, if the first operand consists of a <tt>'-'</tt> followed by one or more characters from the set
     57 {<tt>'e'</tt>, <tt>'E'</tt>, <tt>'n'</tt>}, it shall be treated as a string to be written. The following character sequences shall
     58 be recognized on XSI-conformant systems within any of the arguments:</p>
     59 <dl compact>
     60 <dd></dd>
     61 <dt><tt>\a</tt></dt>
     62 <dd>Write an &lt;alert&gt;.</dd>
     63 <dt><tt>\b</tt></dt>
     64 <dd>Write a &lt;backspace&gt;.</dd>
     65 <dt><tt>\c</tt></dt>
     66 <dd>Suppress the &lt;newline&gt; that otherwise follows the final argument in the output. All characters following the
     67 <tt>'\c'</tt> in the arguments shall be ignored.</dd>
     68 <dt><tt>\f</tt></dt>
     69 <dd>Write a &lt;form-feed&gt;.</dd>
     70 <dt><tt>\n</tt></dt>
     71 <dd>Write a &lt;newline&gt;.</dd>
     72 <dt><tt>\r</tt></dt>
     73 <dd>Write a &lt;carriage-return&gt;.</dd>
     74 <dt><tt>\t</tt></dt>
     75 <dd>Write a &lt;tab&gt;.</dd>
     76 <dt><tt>\v</tt></dt>
     77 <dd>Write a &lt;vertical-tab&gt;.</dd>
     78 <dt><tt>\\</tt></dt>
     79 <dd>Write a &lt;backslash&gt; character.</dd>
     80 <dt><tt>\0</tt><i>num</i></dt>
     81 <dd>Write an 8-bit value that is the zero, one, two, or three-digit octal number <i>num</i>.</dd>
     82 </dl>
     83 </dd>
     84 </dl>
     85 <img src="../images/opt-end.gif" alt="[Option End]" border="0"></blockquote>
     86 <h4 class="mansect"><a name="tag_20_37_06" id="tag_20_37_06"></a>STDIN</h4>
     87 <blockquote>
     88 <p>Not used.</p>
     89 </blockquote>
     90 <h4 class="mansect"><a name="tag_20_37_07" id="tag_20_37_07"></a>INPUT FILES</h4>
     91 <blockquote>
     92 <p>None.</p>
     93 </blockquote>
     94 <h4 class="mansect"><a name="tag_20_37_08" id="tag_20_37_08"></a>ENVIRONMENT VARIABLES</h4>
     95 <blockquote>
     96 <p>The following environment variables shall affect the execution of <i>echo</i>:</p>
     97 <dl compact>
     98 <dd></dd>
     99 <dt><i>LANG</i></dt>
    100 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
    101 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
    102 variables used to determine the values of locale categories.)</dd>
    103 <dt><i>LC_ALL</i></dt>
    104 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
    105 <dt><i>LC_CTYPE</i></dt>
    106 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    107 Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed
    108 to multi-byte characters in arguments). <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
    109 <dt><i>LC_MESSAGES</i></dt>
    110 <dd><br>
    111 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd>
    112 <dt><i>NLSPATH</i></dt>
    113 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
    114 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
    115 "0"></dd>
    116 </dl>
    117 </blockquote>
    118 <h4 class="mansect"><a name="tag_20_37_09" id="tag_20_37_09"></a>ASYNCHRONOUS EVENTS</h4>
    119 <blockquote>
    120 <p>Default.</p>
    121 </blockquote>
    122 <h4 class="mansect"><a name="tag_20_37_10" id="tag_20_37_10"></a>STDOUT</h4>
    123 <blockquote>
    124 <p>The <i>echo</i> utility arguments shall be separated by single &lt;space&gt; characters and a &lt;newline&gt; character shall
    125 follow the last argument. <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
    126 "[Option Start]" border="0"> &nbsp;Output transformations shall occur based on the escape sequences in the input. See the OPERANDS
    127 section. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
    128 </blockquote>
    129 <h4 class="mansect"><a name="tag_20_37_11" id="tag_20_37_11"></a>STDERR</h4>
    130 <blockquote>
    131 <p>The standard error shall be used only for diagnostic messages.</p>
    132 </blockquote>
    133 <h4 class="mansect"><a name="tag_20_37_12" id="tag_20_37_12"></a>OUTPUT FILES</h4>
    134 <blockquote>
    135 <p>None.</p>
    136 </blockquote>
    137 <h4 class="mansect"><a name="tag_20_37_13" id="tag_20_37_13"></a>EXTENDED DESCRIPTION</h4>
    138 <blockquote>
    139 <p>None.</p>
    140 </blockquote>
    141 <h4 class="mansect"><a name="tag_20_37_14" id="tag_20_37_14"></a>EXIT STATUS</h4>
    142 <blockquote>
    143 <p>The following exit values shall be returned:</p>
    144 <dl compact>
    145 <dd></dd>
    146 <dt>&nbsp;0</dt>
    147 <dd>Successful completion.</dd>
    148 <dt>&gt;0</dt>
    149 <dd>An error occurred.</dd>
    150 </dl>
    151 </blockquote>
    152 <h4 class="mansect"><a name="tag_20_37_15" id="tag_20_37_15"></a>CONSEQUENCES OF ERRORS</h4>
    153 <blockquote>
    154 <p>Default.</p>
    155 </blockquote>
    156 <hr>
    157 <div class="box"><em>The following sections are informative.</em></div>
    158 <h4 class="mansect"><a name="tag_20_37_16" id="tag_20_37_16"></a>APPLICATION USAGE</h4>
    159 <blockquote>
    160 <p>It is not possible to use <i>echo</i> portably across all POSIX systems unless escape sequences are omitted, and the first
    161 argument does not consist of a <tt>'-'</tt> followed by one or more characters from the set {<tt>'e'</tt>, <tt>'E'</tt>,
    162 <tt>'n'</tt>}.</p>
    163 <p>The <a href="../utilities/printf.html"><i>printf</i></a> utility can be used portably to emulate any of the traditional
    164 behaviors of the <i>echo</i> utility as follows (assuming that <i>IFS</i> has its standard value or is unset):</p>
    165 <ul>
    166 <li>
    167 <p>The historic System V <i>echo</i> and the requirements on XSI implementations in this volume of POSIX.1-2024 are equivalent
    168 to:</p>
    169 <pre>
    170 <tt>printf "%b\n" "$*"
    171 </tt></pre></li>
    172 <li>
    173 <p>The BSD <i>echo</i> is equivalent to:</p>
    174 <pre>
    175 <tt>if [ "X$1" = "X-n" ]
    176 then
    177     shift
    178     printf "%s" "$*"
    179 else
    180     printf "%s\n" "$*"
    181 fi
    182 </tt></pre></li>
    183 </ul>
    184 <p>New applications are encouraged to use <a href="../utilities/printf.html"><i>printf</i></a> instead of <i>echo</i>.</p>
    185 </blockquote>
    186 <h4 class="mansect"><a name="tag_20_37_17" id="tag_20_37_17"></a>EXAMPLES</h4>
    187 <blockquote>
    188 <p>None.</p>
    189 </blockquote>
    190 <h4 class="mansect"><a name="tag_20_37_18" id="tag_20_37_18"></a>RATIONALE</h4>
    191 <blockquote>
    192 <p>The <i>echo</i> utility has not been made obsolescent because of its extremely widespread use in historical applications.
    193 Conforming applications that wish to do prompting without &lt;newline&gt; characters or that could possibly be expecting to echo a
    194 string consisting of a <tt>'-'</tt> followed by one or more characters from the set {<tt>'e'</tt>, <tt>'E'</tt>, <tt>'n'</tt>}
    195 should use the <a href="../utilities/printf.html"><i>printf</i></a> utility.</p>
    196 <p>At the time that the IEEE&nbsp;Std&nbsp;1003.2-1992 standard was being developed, the two different historical versions of
    197 <i>echo</i> that were considered for standardization varied in incompatible ways.</p>
    198 <p>The BSD <i>echo</i> checked the first argument for the string <b>-n</b> which caused it to suppress the &lt;newline&gt; that
    199 would otherwise follow the final argument in the output.</p>
    200 <p>The System V <i>echo</i> treated all arguments as strings to be written, but allowed escape sequences within them, as described
    201 for XSI implementations in the OPERANDS section, including <tt>\c</tt> to suppress a trailing &lt;newline&gt;.</p>
    202 <p>Thus the IEEE&nbsp;Std&nbsp;1003.2-1992 standard said that the behavior was implementation-defined if the first operand is
    203 <b>-n</b> or if any of the operands contain a &lt;backslash&gt; character. It also specified that the <i>echo</i> utility does not
    204 support Utility Syntax Guideline 10 because historical applications depended on <i>echo</i> to echo <i>all</i> of its arguments,
    205 except for the <b>-n</b> first argument in the BSD version.</p>
    206 <p>The Single UNIX Specification, Version 1 required the System V behavior, and this became the XSI requirement when Version 2 and
    207 POSIX.2 were merged with POSIX.1 to form the joint IEEE&nbsp;Std&nbsp;1003.1-2001 / Single UNIX Specification, Version 3
    208 standard.</p>
    209 <p>This standard now treats a first operand of <b>-e</b> or <b>-E</b> the same as <b>-n</b> in recognition that support for them
    210 has become more widespread in non-XSI implementations. Where supported, <b>-e</b> enables processing of escape sequences in the
    211 remaining operands (in situations where it is disabled by default), and <b>-E</b> disables it (in situations where it is enabled by
    212 default). A first operand containing a combination of these three letters, in the same manner as option grouping, also results in
    213 implementation-defined behavior.</p>
    214 </blockquote>
    215 <h4 class="mansect"><a name="tag_20_37_19" id="tag_20_37_19"></a>FUTURE DIRECTIONS</h4>
    216 <blockquote>
    217 <p>None.</p>
    218 </blockquote>
    219 <h4 class="mansect"><a name="tag_20_37_20" id="tag_20_37_20"></a>SEE ALSO</h4>
    220 <blockquote>
    221 <p><a href="../utilities/printf.html#tag_20_96"><i>printf</i></a></p>
    222 <p>XBD <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> , <a href=
    223 "../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p>
    224 </blockquote>
    225 <h4 class="mansect"><a name="tag_20_37_21" id="tag_20_37_21"></a>CHANGE HISTORY</h4>
    226 <blockquote>
    227 <p>First released in Issue 2.</p>
    228 </blockquote>
    229 <h4 class="mansect"><a name="tag_20_37_22" id="tag_20_37_22"></a>Issue 5</h4>
    230 <blockquote>
    231 <p>In the OPTIONS section, the last sentence is changed to indicate that implementations &quot;do not&quot; support any options; in the
    232 previous issue this said &quot;need not&quot;.</p>
    233 </blockquote>
    234 <h4 class="mansect"><a name="tag_20_37_23" id="tag_20_37_23"></a>Issue 6</h4>
    235 <blockquote>
    236 <p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
    237 <ul>
    238 <li>
    239 <p>A set of character sequences is defined as <i>string</i> operands.</p>
    240 </li>
    241 <li>
    242 <p><i>LC_CTYPE</i> is added to the list of environment variables affecting <i>echo</i>.</p>
    243 </li>
    244 <li>
    245 <p>In the OPTIONS section, implementations shall not support any options.</p>
    246 </li>
    247 </ul>
    248 <p>IEEE&nbsp;Std&nbsp;1003.1-2001/Cor&nbsp;1-2002, item XCU/TC1/D6/21 is applied, so that the <i>echo</i> utility can accommodate
    249 historical BSD behavior.</p>
    250 </blockquote>
    251 <h4 class="mansect"><a name="tag_20_37_24" id="tag_20_37_24"></a>Issue 7</h4>
    252 <blockquote>
    253 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p>
    254 </blockquote>
    255 <h4 class="mansect"><a name="tag_20_37_25" id="tag_20_37_25"></a>Issue 8</h4>
    256 <blockquote>
    257 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    258 <p>Austin Group Defect 1222 is applied, making the results implementation-defined, on systems that are not XSI-conformant, if the
    259 first operand consists of a <tt>'-'</tt> followed by one or more characters from the set {<tt>'e'</tt>, <tt>'E'</tt>,
    260 <tt>'n'</tt>}.</p>
    261 </blockquote>
    262 <div class="box"><em>End of informative text.</em></div>
    263 <hr>
    264 <p>&nbsp;</p>
    265 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    266 <hr size="2" noshade>
    267 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    268 POSIX™ is a Trademark of The IEEE.<br>
    269 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    270 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    271 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    272 ]</font></center>
    273 <hr size="2" noshade>
    274 <div class="NAVHEADER">
    275 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    276 <tr class="nav">
    277 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/du.html" accesskey="P">&lt;&lt;&lt;
    278 Previous</a></td>
    279 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    280 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/ed.html" accesskey="N">Next &gt;&gt;&gt;</a></td>
    281 </tr>
    282 </table>
    283 <hr align="left" width="100%"></div>
    284 </body>
    285 </html>