isposix

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

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

dirname.html (12941B)


      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>dirname</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/diff.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/du.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="dirname" id="dirname"></a> <a name="tag_20_35" id="tag_20_35"></a><!-- dirname -->
     28 <h4 class="mansect"><a name="tag_20_35_01" id="tag_20_35_01"></a>NAME</h4>
     29 <blockquote>dirname — return the directory portion of a pathname</blockquote>
     30 <h4 class="mansect"><a name="tag_20_35_02" id="tag_20_35_02"></a>SYNOPSIS</h4>
     31 <blockquote class="synopsis">
     32 <p><code><tt>dirname</tt> <i>string</i></code></p>
     33 </blockquote>
     34 <h4 class="mansect"><a name="tag_20_35_03" id="tag_20_35_03"></a>DESCRIPTION</h4>
     35 <blockquote>
     36 <p>The <i>string</i> operand shall be treated as a pathname, as defined in XBD <a href=
     37 "../basedefs/V1_chap03.html#tag_03_254"><i>3.254 Pathname</i></a> , and shall be converted to a pathname of the directory
     38 containing the entry of the final pathname component. The resulting string shall be written to standard output. The <i>dirname</i>
     39 utility shall not perform pathname resolution; the result shall not be affected by whether or not a file with the pathname
     40 <i>string</i> exists or by its file type. Trailing <tt>'/'</tt> characters in <i>string</i> that are not also leading <tt>'/'</tt>
     41 characters shall not be counted as part of the pathname. If the pathname does not contain a <tt>'/'</tt>, the resulting string
     42 shall be <tt>"."</tt>. If <i>string</i> is an empty string, the resulting string shall be <tt>"."</tt>.</p>
     43 <p>It is unspecified whether redundant <tt>'/'</tt> characters and <tt>'.'</tt> pathname components in <i>string</i> are removed
     44 after determining the pathname to output. However, <tt>".."</tt> pathname components occurring prior to the final component shall
     45 not be removed.</p>
     46 </blockquote>
     47 <h4 class="mansect"><a name="tag_20_35_04" id="tag_20_35_04"></a>OPTIONS</h4>
     48 <blockquote>
     49 <p>None.</p>
     50 </blockquote>
     51 <h4 class="mansect"><a name="tag_20_35_05" id="tag_20_35_05"></a>OPERANDS</h4>
     52 <blockquote>
     53 <p>The following operand shall be supported:</p>
     54 <dl compact>
     55 <dd></dd>
     56 <dt><i>string</i></dt>
     57 <dd>A string.</dd>
     58 </dl>
     59 </blockquote>
     60 <h4 class="mansect"><a name="tag_20_35_06" id="tag_20_35_06"></a>STDIN</h4>
     61 <blockquote>
     62 <p>Not used.</p>
     63 </blockquote>
     64 <h4 class="mansect"><a name="tag_20_35_07" id="tag_20_35_07"></a>INPUT FILES</h4>
     65 <blockquote>
     66 <p>None.</p>
     67 </blockquote>
     68 <h4 class="mansect"><a name="tag_20_35_08" id="tag_20_35_08"></a>ENVIRONMENT VARIABLES</h4>
     69 <blockquote>
     70 <p>The following environment variables shall affect the execution of <i>dirname</i>:</p>
     71 <dl compact>
     72 <dd></dd>
     73 <dt><i>LANG</i></dt>
     74 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href=
     75 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization
     76 variables used to determine the values of locale categories.)</dd>
     77 <dt><i>LC_ALL</i></dt>
     78 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
     79 <dt><i>LC_CTYPE</i></dt>
     80 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
     81 opposed to multi-byte characters in arguments).</dd>
     82 <dt><i>LC_MESSAGES</i></dt>
     83 <dd><br>
     84 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd>
     85 <dt><i>NLSPATH</i></dt>
     86 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
     87 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border=
     88 "0"></dd>
     89 </dl>
     90 </blockquote>
     91 <h4 class="mansect"><a name="tag_20_35_09" id="tag_20_35_09"></a>ASYNCHRONOUS EVENTS</h4>
     92 <blockquote>
     93 <p>Default.</p>
     94 </blockquote>
     95 <h4 class="mansect"><a name="tag_20_35_10" id="tag_20_35_10"></a>STDOUT</h4>
     96 <blockquote>
     97 <p>The <i>dirname</i> utility shall write a line to the standard output in the following format:</p>
     98 <pre>
     99 <tt>"%s\n", &lt;</tt><i>resulting string</i><tt>&gt;
    100 </tt></pre></blockquote>
    101 <h4 class="mansect"><a name="tag_20_35_11" id="tag_20_35_11"></a>STDERR</h4>
    102 <blockquote>
    103 <p>The standard error shall be used only for diagnostic messages.</p>
    104 </blockquote>
    105 <h4 class="mansect"><a name="tag_20_35_12" id="tag_20_35_12"></a>OUTPUT FILES</h4>
    106 <blockquote>
    107 <p>None.</p>
    108 </blockquote>
    109 <h4 class="mansect"><a name="tag_20_35_13" id="tag_20_35_13"></a>EXTENDED DESCRIPTION</h4>
    110 <blockquote>
    111 <p>None.</p>
    112 </blockquote>
    113 <h4 class="mansect"><a name="tag_20_35_14" id="tag_20_35_14"></a>EXIT STATUS</h4>
    114 <blockquote>
    115 <p>The following exit values shall be returned:</p>
    116 <dl compact>
    117 <dd></dd>
    118 <dt>&nbsp;0</dt>
    119 <dd>Successful completion.</dd>
    120 <dt>&gt;0</dt>
    121 <dd>An error occurred.</dd>
    122 </dl>
    123 </blockquote>
    124 <h4 class="mansect"><a name="tag_20_35_15" id="tag_20_35_15"></a>CONSEQUENCES OF ERRORS</h4>
    125 <blockquote>
    126 <p>Default.</p>
    127 </blockquote>
    128 <hr>
    129 <div class="box"><em>The following sections are informative.</em></div>
    130 <h4 class="mansect"><a name="tag_20_35_16" id="tag_20_35_16"></a>APPLICATION USAGE</h4>
    131 <blockquote>
    132 <p>The definition of <i>pathname</i> specifies implementation-defined behavior for pathnames starting with two &lt;slash&gt;
    133 characters. Therefore, applications shall not arbitrarily add &lt;slash&gt; characters to the beginning of a pathname unless they
    134 can ensure that there are more or less than two or are prepared to deal with the implementation-defined consequences.</p>
    135 </blockquote>
    136 <h4 class="mansect"><a name="tag_20_35_17" id="tag_20_35_17"></a>EXAMPLES</h4>
    137 <blockquote>
    138 <p>The EXAMPLES section of the <a href="../functions/basename.html"><i>basename</i>()</a> function (see XSH <a href=
    139 "../functions/basename.html#tag_17_42"><i>basename</i></a> ) includes a table showing examples of the results of processing several
    140 sample pathnames by the <a href="../functions/basename.html"><i>basename</i>()</a> and <a href=
    141 "../functions/dirname.html"><i>dirname</i>()</a> functions and by the <a href="../utilities/basename.html"><i>basename</i></a> and
    142 <i>dirname</i> utilities.</p>
    143 <p>See also the examples for the <a href="../utilities/basename.html"><i>basename</i></a> utility.</p>
    144 </blockquote>
    145 <h4 class="mansect"><a name="tag_20_35_18" id="tag_20_35_18"></a>RATIONALE</h4>
    146 <blockquote>
    147 <p>The behaviors of <a href="../utilities/basename.html"><i>basename</i></a> and <i>dirname</i> in this volume of POSIX.1-2024 have
    148 been coordinated so that when <i>string</i> is a valid pathname:</p>
    149 <pre>
    150 <tt>$(basename -- "</tt><i>string</i><tt>")
    151 </tt></pre>
    152 <p>would be a valid filename for the file in the directory:</p>
    153 <pre>
    154 <tt>$(dirname -- "</tt><i>string</i><tt>")
    155 </tt></pre>
    156 <p>This would not work for the versions of these utilities in early proposals due to the way processing of trailing &lt;slash&gt;
    157 characters was specified. Consideration was given to leaving processing unspecified if there were trailing &lt;slash&gt;
    158 characters, but this cannot be done; XBD <a href="../basedefs/V1_chap03.html#tag_03_254"><i>3.254 Pathname</i></a> allows trailing
    159 &lt;slash&gt; characters. The <a href="../utilities/basename.html"><i>basename</i></a> and <i>dirname</i> utilities have to specify
    160 consistent handling for all valid pathnames.</p>
    161 <p>The <i>dirname</i> utility is not specified in terms of the <a href="../functions/dirname.html"><i>dirname</i>()</a> function,
    162 because the two may produce slightly different output where both output forms are still compliant. An implementation should prefer
    163 the shortest output possible; however, this is not required, in part because earlier versions of the standard did not permit
    164 elision of redundant &lt;slash&gt; characters or dot (<tt>'.'</tt>) components. Removal of the dot-dot (<tt>".."</tt>) pathname
    165 component is not permitted, because eliding it correctly would require performing pathname resolution to ensure the resulting
    166 string would still point to the correct pathname if the original string resolved as a pathname. On implementations where pathname
    167 <tt>"//"</tt> has an implementation-defined meaning distinct from the pathname <tt>"/"</tt>, the dirname of <tt>"//"</tt> will be
    168 <tt>"//"</tt>.</p>
    169 </blockquote>
    170 <h4 class="mansect"><a name="tag_20_35_19" id="tag_20_35_19"></a>FUTURE DIRECTIONS</h4>
    171 <blockquote>
    172 <p>If this utility is directed to display a pathname that contains any bytes that have the encoded value of a &lt;newline&gt;
    173 character when &lt;newline&gt; is a terminator or separator in the output format being used, implementations are encouraged to
    174 treat this as an error. A future version of this standard may require implementations to treat this as an error.</p>
    175 </blockquote>
    176 <h4 class="mansect"><a name="tag_20_35_20" id="tag_20_35_20"></a>SEE ALSO</h4>
    177 <blockquote>
    178 <p><a href="../utilities/V3_chap02.html#tag_19_05"><i>2.5 Parameters and Variables</i></a> , <a href=
    179 "../utilities/basename.html#tag_20_07"><i>basename</i></a></p>
    180 <p>XBD <a href="../basedefs/V1_chap03.html#tag_03_254"><i>3.254 Pathname</i></a> , <a href=
    181 "../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a></p>
    182 <p>XSH <a href="../functions/basename.html#tag_17_42"><i>basename</i></a> , <a href=
    183 "../functions/dirname.html#tag_17_108"><i>dirname</i></a></p>
    184 </blockquote>
    185 <h4 class="mansect"><a name="tag_20_35_21" id="tag_20_35_21"></a>CHANGE HISTORY</h4>
    186 <blockquote>
    187 <p>First released in Issue 2.</p>
    188 </blockquote>
    189 <h4 class="mansect"><a name="tag_20_35_22" id="tag_20_35_22"></a>Issue 7</h4>
    190 <blockquote>
    191 <p>POSIX.1-2008, Technical Corrigendum 1, XCU/TC1-2008/0083 [192,430], XCU/TC1-2008/0084 [192], and XCU/TC1-2008/0085 [192] are
    192 applied.</p>
    193 <p>POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0086 [612], XCU/TC2-2008/0087 [620], and XCU/TC2-2008/0088 [612] are
    194 applied.</p>
    195 </blockquote>
    196 <h4 class="mansect"><a name="tag_20_35_23" id="tag_20_35_23"></a>Issue 8</h4>
    197 <blockquote>
    198 <p>Austin Group Defect 251 is applied, encouraging implementations to report an error if a utility is directed to display a
    199 pathname that contains any bytes that have the encoded value of a &lt;newline&gt; character when &lt;newline&gt; is a terminator or
    200 separator in the output format being used.</p>
    201 <p>Austin Group Defect 1073 is applied, replacing the DESCRIPTION section with one that matches the <a href=
    202 "../functions/dirname.html"><i>dirname</i>()</a> function.</p>
    203 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p>
    204 </blockquote>
    205 <div class="box"><em>End of informative text.</em></div>
    206 <hr>
    207 <p>&nbsp;</p>
    208 <a href="#top"><span class="topOfPage">return to top of page</span></a><br>
    209 <hr size="2" noshade>
    210 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br>
    211 POSIX™ is a Trademark of The IEEE.<br>
    212 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br>
    213 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
    214 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a>
    215 ]</font></center>
    216 <hr size="2" noshade>
    217 <div class="NAVHEADER">
    218 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0">
    219 <tr class="nav">
    220 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/diff.html" accesskey="P">&lt;&lt;&lt;
    221 Previous</a></td>
    222 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td>
    223 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/du.html" accesskey="N">Next &gt;&gt;&gt;</a></td>
    224 </tr>
    225 </table>
    226 <hr align="left" width="100%"></div>
    227 </body>
    228 </html>