Un outil pour savoir si une commande est posix - retour accueil
git clone git://bebou.netlib.re/isposix
Log | Files | Refs | README |
locale.html (21079B)
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>locale</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/ln.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/localedef.html" accesskey="N">Next 19 >>></a></td> 20 </tr> 21 </table> 22 <hr align="left" width="100%"></div> 23 <script language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> 24 <center><font size="2">The Open Group Base Specifications Issue 8<br> 25 IEEE Std 1003.1-2024<br> 26 Copyright © 2001-2024 The IEEE and The Open Group</font></center> 27 <hr size="2" noshade> 28 <a name="top" id="top"></a> <a name="locale" id="locale"></a> <a name="tag_20_68" id="tag_20_68"></a><!-- locale --> 29 <h4 class="mansect"><a name="tag_20_68_01" id="tag_20_68_01"></a>NAME</h4> 30 <blockquote>locale — get locale-specific information</blockquote> 31 <h4 class="mansect"><a name="tag_20_68_02" id="tag_20_68_02"></a>SYNOPSIS</h4> 32 <blockquote class="synopsis"> 33 <p><code><tt>locale</tt> <b>[</b><tt>-a|-m</tt><b>]</b> <tt><br> 34 <br> 35 locale</tt> <b>[</b><tt>-ck</tt><b>]</b> <i>name</i><tt>...<br></tt></code></p> 36 </blockquote> 37 <h4 class="mansect"><a name="tag_20_68_03" id="tag_20_68_03"></a>DESCRIPTION</h4> 38 <blockquote> 39 <p>The <i>locale</i> utility shall write information about the current locale environment, or all public locales, to the standard 40 output. For the purposes of this section, a <i>public locale</i> is one provided by the implementation that is accessible to the 41 application.</p> 42 <p>When <i>locale</i> is invoked without any arguments, it shall summarize the current locale environment for each locale category 43 as determined by the settings of the environment variables defined in XBD <a href="../basedefs/V1_chap07.html#tag_07"><i>7. 44 Locale</i></a> .</p> 45 <p>When invoked with operands, it shall write values that have been assigned to the keywords in the locale categories, as 46 follows:</p> 47 <ul> 48 <li> 49 <p>Specifying a keyword name shall select the named keyword and the category containing that keyword.</p> 50 </li> 51 <li> 52 <p>Specifying a category name shall select the named category and all keywords in that category.</p> 53 </li> 54 </ul> 55 </blockquote> 56 <h4 class="mansect"><a name="tag_20_68_04" id="tag_20_68_04"></a>OPTIONS</h4> 57 <blockquote> 58 <p>The <i>locale</i> utility shall conform to XBD <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax 59 Guidelines</i></a> .</p> 60 <p>The following options shall be supported:</p> 61 <dl compact> 62 <dd></dd> 63 <dt><b>-a</b></dt> 64 <dd>Write information about all available public locales. The available locales shall include <b>POSIX</b>, representing the POSIX 65 locale. The manner in which the implementation determines what other locales are available is implementation-defined.</dd> 66 <dt><b>-c</b></dt> 67 <dd>Write the names of selected locale categories; see the STDOUT section. The <b>-c</b> option increases readability when more 68 than one category is selected (for example, via more than one keyword name or via a category name). It is valid both with and 69 without the <b>-k</b> option.</dd> 70 <dt><b>-k</b></dt> 71 <dd>Write the names and values of selected keywords. The implementation may omit values for some keywords; see the OPERANDS 72 section.</dd> 73 <dt><b>-m</b></dt> 74 <dd>Write names of available charmaps; see XBD <a href="../basedefs/V1_chap06.html#tag_06_01"><i>6.1 Portable Character Set</i></a> 75 .</dd> 76 </dl> 77 </blockquote> 78 <h4 class="mansect"><a name="tag_20_68_05" id="tag_20_68_05"></a>OPERANDS</h4> 79 <blockquote> 80 <p>The following operand shall be supported:</p> 81 <dl compact> 82 <dd></dd> 83 <dt><i>name</i></dt> 84 <dd>The name of a locale category as defined in XBD <a href="../basedefs/V1_chap07.html#tag_07"><i>7. Locale</i></a> , the name of 85 a keyword in a locale category, or the reserved name <b>charmap</b>. The named category or keyword shall be selected for output. If 86 a single <i>name</i> represents both a locale category name and a keyword name in the current locale, the results are unspecified. 87 Otherwise, both category and keyword names can be specified as <i>name</i> operands, in any sequence. It is implementation-defined 88 whether any keyword values are written for the categories <i>LC_CTYPE</i> and <i>LC_COLLATE .</i></dd> 89 </dl> 90 </blockquote> 91 <h4 class="mansect"><a name="tag_20_68_06" id="tag_20_68_06"></a>STDIN</h4> 92 <blockquote> 93 <p>Not used.</p> 94 </blockquote> 95 <h4 class="mansect"><a name="tag_20_68_07" id="tag_20_68_07"></a>INPUT FILES</h4> 96 <blockquote> 97 <p>None.</p> 98 </blockquote> 99 <h4 class="mansect"><a name="tag_20_68_08" id="tag_20_68_08"></a>ENVIRONMENT VARIABLES</h4> 100 <blockquote> 101 <p>The following environment variables shall affect the execution of <i>locale</i>:</p> 102 <dl compact> 103 <dd></dd> 104 <dt><i>LANG</i></dt> 105 <dd>Provide a default value for the internationalization variables that are unset or null. (See XBD <a href= 106 "../basedefs/V1_chap08.html#tag_08_02"><i>8.2 Internationalization Variables</i></a> for the precedence of internationalization 107 variables used to determine the values of locale categories.)</dd> 108 <dt><i>LC_ALL</i></dt> 109 <dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd> 110 <dt><i>LC_CTYPE</i></dt> 111 <dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as 112 opposed to multi-byte characters in arguments and input files).</dd> 113 <dt><i>LC_MESSAGES</i></dt> 114 <dd><br> 115 Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.</dd> 116 <dt><i>NLSPATH</i></dt> 117 <dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> 118 Determine the location of messages objects and message catalogs. <img src="../images/opt-end.gif" alt="[Option End]" border= 119 "0"></dd> 120 </dl> 121 <p>The application shall ensure that the <i>LANG ,</i> <i>LC_* ,</i> and <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> 122 <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> <i>NLSPATH</i> <img src="../images/opt-end.gif" alt= 123 "[Option End]" border="0"> environment variables specify the current locale environment to be written out; they shall be used 124 if the <b>-a</b> option is not specified.</p> 125 </blockquote> 126 <h4 class="mansect"><a name="tag_20_68_09" id="tag_20_68_09"></a>ASYNCHRONOUS EVENTS</h4> 127 <blockquote> 128 <p>Default.</p> 129 </blockquote> 130 <h4 class="mansect"><a name="tag_20_68_10" id="tag_20_68_10"></a>STDOUT</h4> 131 <blockquote> 132 <p>The <i>LANG</i> variable shall be written first using the format:</p> 133 <pre> 134 <tt>"LANG=%s\n", <</tt><i>value</i><tt>> 135 </tt></pre> 136 <p>If <i>LANG</i> is not set or is an empty string, the value is the empty string.</p> 137 <p>If <i>locale</i> is invoked without any options or operands, the names and values of the <i>LC_*</i> environment variables 138 described in this volume of POSIX.1-2024 shall be written to the standard output, one variable per line, and each line using the 139 following format. Only those variables set in the environment and not overridden by <i>LC_ALL</i> shall be written using this 140 format:</p> 141 <pre> 142 <tt>"%s=%s\n", <</tt><i>variable_name</i><tt>>, <</tt><i>value</i><tt>> 143 </tt></pre> 144 <p>The names of those <i>LC_*</i> variables associated with locale categories defined in this volume of POSIX.1-2024 that are not 145 set in the environment or are overridden by <i>LC_ALL</i> shall be written in the following format:</p> 146 <pre> 147 <tt>"%s=\"%s\"\n", <</tt><i>variable_name</i><tt>>, <</tt><i>implied value</i><tt>> 148 </tt></pre> 149 <p>The <<i>implied value</i>> shall be the name of the locale that has been selected for that category by the 150 implementation, based on the values in <i>LANG</i> and <i>LC_ALL ,</i> as described in XBD <a href= 151 "../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> .</p> 152 <p>The <<i>value</i>> and <<i>implied value</i>> shown above shall be properly quoted for possible later reentry 153 to the shell. The <<i>value</i>> shall not be quoted using double-quotes (so that it can be distinguished by the user from 154 the <<i>implied value</i>> case, which always requires double-quotes).</p> 155 <p>The <i>LC_ALL</i> variable shall be written last, using the first format shown above. If it is not set, it shall be written 156 as:</p> 157 <pre> 158 <tt>"LC_ALL=\n" 159 </tt></pre> 160 <p>If any arguments are specified:</p> 161 <ol> 162 <li> 163 <p>If the <b>-a</b> option is specified, the names of all the public locales shall be written, each in the following format:</p> 164 <pre> 165 <tt>"%s\n", <</tt><i>locale name</i><tt>> 166 </tt></pre></li> 167 <li> 168 <p>If the <b>-c</b> option is specified, the names of all selected categories shall be written, each in the following format:</p> 169 <pre> 170 <tt>"%s\n", <</tt><i>category name</i><tt>> 171 </tt></pre> 172 <p>If keywords are also selected for writing (see following items), the category name output shall precede the keyword output for 173 that category.</p> 174 <p>If the <b>-c</b> option is not specified, the names of the categories shall not be written; only the keywords, as selected by 175 the <<i>name</i>> operand, shall be written.</p> 176 </li> 177 <li> 178 <p>If the <b>-k</b> option is specified, the names and values of selected keywords shall be written. If a value is non-numeric and 179 is not a compound keyword value, it shall be written in the following format:</p> 180 <pre> 181 <tt>"%s=\"%s\"\n", <</tt><i>keyword name</i><tt>>, <</tt><i>keyword value</i><tt>> 182 </tt></pre> 183 <p>If a value is a non-numeric compound keyword value, it shall either be written in the format:</p> 184 <pre> 185 <tt>"%s=\"%s\"\n", <</tt><i>keyword name</i><tt>>, <</tt><i>keyword value</i><tt>> 186 </tt></pre> 187 <p>where the <<i>keyword value</i>> is a single string of values separated by <semicolon> characters, or it shall be 188 written in the format:</p> 189 <pre> 190 <tt>"%s=%s\n", <</tt><i>keyword name</i><tt>>, <</tt><i>keyword value</i><tt>> 191 </tt></pre> 192 <p>where the <<i>keyword value</i>> is encoded as a set of strings, each enclosed in double-quotation-marks, separated by 193 <semicolon> characters.</p> 194 <p>If the keyword was <b>charmap</b>, the name of the charmap (if any) that was specified via the <a href= 195 "../utilities/localedef.html"><i>localedef</i></a> <b>-f</b> option when the locale was created shall be written, with the word 196 <b>charmap</b> as <<i>keyword name</i>>.</p> 197 <p>If a value is numeric, it shall be written in one of the following formats:</p> 198 <pre> 199 <tt>"%s=%d\n", <</tt><i>keyword name</i><tt>>, <</tt><i>keyword value</i><tt>> 200 <br> 201 "%s=%c%o\n", <</tt><i>keyword name</i><tt>>, <</tt><i>escape character</i><tt>>, <</tt><i>keyword value</i><tt>> 202 <br> 203 "%s=%cx%x\n", <</tt><i>keyword name</i><tt>>, <</tt><i>escape character</i><tt>>, <</tt><i>keyword value</i><tt>> 204 </tt></pre> 205 <p>where the <<i>escape character</i>> is that identified by the <b>escape_char</b> keyword in the current locale; see 206 XBD <a href="../basedefs/V1_chap07.html#tag_07_03"><i>7.3 Locale Definition</i></a> .</p> 207 <p>Compound keyword values (list entries) shall be separated in the output by <semicolon> characters. When included in 208 keyword values, the <semicolon>, <backslash>, double-quote, and any control character shall be preceded (escaped) with 209 the escape character.</p> 210 </li> 211 <li> 212 <p>If the <b>-k</b> option is not specified, selected keyword values shall be written, each in the following format:</p> 213 <pre> 214 <tt>"%s\n", <</tt><i>keyword value</i><tt>> 215 </tt></pre> 216 <p>If the keyword was <b>charmap</b>, the name of the charmap (if any) that was specified via the <a href= 217 "../utilities/localedef.html"><i>localedef</i></a> <b>-f</b> option when the locale was created shall be written.</p> 218 </li> 219 <li> 220 <p>If the <b>-m</b> option is specified, then a list of all available charmaps shall be written, each in the format:</p> 221 <pre> 222 <tt>"%s\n", <</tt><i>charmap</i><tt>> 223 </tt></pre> 224 <p>where <<i>charmap</i>> is in a format suitable for use as the option-argument to the <a href= 225 "../utilities/localedef.html"><i>localedef</i></a> <b>-f</b> option.</p> 226 </li> 227 </ol> 228 </blockquote> 229 <h4 class="mansect"><a name="tag_20_68_11" id="tag_20_68_11"></a>STDERR</h4> 230 <blockquote> 231 <p>The standard error shall be used only for diagnostic messages.</p> 232 </blockquote> 233 <h4 class="mansect"><a name="tag_20_68_12" id="tag_20_68_12"></a>OUTPUT FILES</h4> 234 <blockquote> 235 <p>None.</p> 236 </blockquote> 237 <h4 class="mansect"><a name="tag_20_68_13" id="tag_20_68_13"></a>EXTENDED DESCRIPTION</h4> 238 <blockquote> 239 <p>None.</p> 240 </blockquote> 241 <h4 class="mansect"><a name="tag_20_68_14" id="tag_20_68_14"></a>EXIT STATUS</h4> 242 <blockquote> 243 <p>The following exit values shall be returned:</p> 244 <dl compact> 245 <dd></dd> 246 <dt> 0</dt> 247 <dd>All the requested information was found and output successfully.</dd> 248 <dt>>0</dt> 249 <dd>An error occurred.</dd> 250 </dl> 251 </blockquote> 252 <h4 class="mansect"><a name="tag_20_68_15" id="tag_20_68_15"></a>CONSEQUENCES OF ERRORS</h4> 253 <blockquote> 254 <p>Default.</p> 255 </blockquote> 256 <hr> 257 <div class="box"><em>The following sections are informative.</em></div> 258 <h4 class="mansect"><a name="tag_20_68_16" id="tag_20_68_16"></a>APPLICATION USAGE</h4> 259 <blockquote> 260 <p>If the <i>LANG</i> environment variable is not set or set to an empty value, or one of the <i>LC_*</i> environment variables is 261 set to an unrecognized value, the actual locales assumed (if any) are implementation-defined as described in XBD <a href= 262 "../basedefs/V1_chap08.html#tag_08"><i>8. Environment Variables</i></a> .</p> 263 <p>Implementations are not required to write out the actual values for keywords in the categories <i>LC_CTYPE</i> and <i>LC_COLLATE 264 ;</i> however, they must write out the categories (allowing an application to determine, for example, which character classes are 265 available).</p> 266 </blockquote> 267 <h4 class="mansect"><a name="tag_20_68_17" id="tag_20_68_17"></a>EXAMPLES</h4> 268 <blockquote> 269 <p>In the following examples, the assumption is that locale environment variables are set as follows:</p> 270 <pre> 271 <tt>LANG=locale_x 272 LC_COLLATE=locale_y 273 </tt></pre> 274 <p>The command <i>locale</i> would result in the following output:</p> 275 <pre> 276 <tt>LANG=locale_x 277 LC_CTYPE="locale_x" 278 LC_COLLATE=locale_y 279 LC_TIME="locale_x" 280 LC_NUMERIC="locale_x" 281 LC_MONETARY="locale_x" 282 LC_MESSAGES="locale_x" 283 LC_ALL= 284 </tt></pre> 285 <p>The order of presentation of the categories is not specified by this volume of POSIX.1-2024.</p> 286 <p>The command:</p> 287 <pre> 288 <tt>LC_ALL=POSIX locale -ck decimal_point 289 </tt></pre> 290 <p>would produce:</p> 291 <pre> 292 <tt>LC_NUMERIC 293 decimal_point="." 294 </tt></pre> 295 <p>The following command shows an application of <i>locale</i> to determine whether a user-supplied response is affirmative:</p> 296 <pre> 297 <tt>printf 'Prompt for response: ' 298 read response 299 if printf "%s\n" "$response" | grep -Eq -- "$(locale yesexpr)" 300 then 301 affirmative processing goes here 302 else 303 non-affirmative processing goes here 304 fi 305 </tt></pre></blockquote> 306 <h4 class="mansect"><a name="tag_20_68_18" id="tag_20_68_18"></a>RATIONALE</h4> 307 <blockquote> 308 <p>The output for categories <i>LC_CTYPE</i> and <i>LC_COLLATE</i> has been made implementation-defined because there is a 309 questionable value in having a shell script receive an entire array of characters. It is also difficult to return a logical 310 collation description, short of returning a complete <a href="../utilities/localedef.html"><i>localedef</i></a> source.</p> 311 <p>The <b>-m</b> option was included to allow applications to query for the existence of charmaps. The output is a list of the 312 charmaps (implementation-supplied and user-supplied, if any) on the system.</p> 313 <p>The <b>-c</b> option was included for readability when more than one category is selected (for example, via more than one 314 keyword name or via a category name). It is valid both with and without the <b>-k</b> option.</p> 315 <p>The <b>charmap</b> keyword, which returns the name of the charmap (if any) that was used when the current locale was created, 316 was included to allow applications needing the information to retrieve it.</p> 317 <p>According to XBD <a href="../basedefs/V1_chap06.html#tag_06_01"><i>6.1 Portable Character Set</i></a> , the standard requires 318 that all supported locales must have the same encoding for <period> and <slash>, because these two characters are used 319 within the locale-independent pathname resolution sequence. Therefore, it would be an error if <i>locale</i> <b>-a</b> listed both 320 ASCII and EBCDIC-based locales, since those two encodings do not share the same representation for either <period> or 321 <slash>. Any system that supports both environments would be expected to provide two POSIX locales, one in either codeset, 322 where only the locales appropriate to the current environment can be visible at a time. In an XSI-compliant implementation, the 323 <a href="../utilities/dd.html"><i>dd</i></a> utility is the only portable means for performing conversions between the two 324 character sets.</p> 325 </blockquote> 326 <h4 class="mansect"><a name="tag_20_68_19" id="tag_20_68_19"></a>FUTURE DIRECTIONS</h4> 327 <blockquote> 328 <p>None.</p> 329 </blockquote> 330 <h4 class="mansect"><a name="tag_20_68_20" id="tag_20_68_20"></a>SEE ALSO</h4> 331 <blockquote> 332 <p><a href="../utilities/localedef.html#"><i>localedef</i></a></p> 333 <p>XBD <a href="../basedefs/V1_chap06.html#tag_06_01"><i>6.1 Portable Character Set</i></a> , <a href= 334 "../basedefs/V1_chap07.html#tag_07"><i>7. Locale</i></a> , <a href="../basedefs/V1_chap08.html#tag_08"><i>8. Environment 335 Variables</i></a> , <a href="../basedefs/V1_chap12.html#tag_12_02"><i>12.2 Utility Syntax Guidelines</i></a></p> 336 </blockquote> 337 <h4 class="mansect"><a name="tag_20_68_21" id="tag_20_68_21"></a>CHANGE HISTORY</h4> 338 <blockquote> 339 <p>First released in Issue 4.</p> 340 </blockquote> 341 <h4 class="mansect"><a name="tag_20_68_22" id="tag_20_68_22"></a>Issue 5</h4> 342 <blockquote> 343 <p>The FUTURE DIRECTIONS section is added.</p> 344 </blockquote> 345 <h4 class="mansect"><a name="tag_20_68_23" id="tag_20_68_23"></a>Issue 6</h4> 346 <blockquote> 347 <p>The normative text is reworded to avoid use of the term "must" for application requirements.</p> 348 <p>IEEE Std 1003.1-2001/Cor 1-2002, item XCU/TC1/D6/30 is applied, correcting an editorial error in the STDOUT 349 section.</p> 350 </blockquote> 351 <h4 class="mansect"><a name="tag_20_68_24" id="tag_20_68_24"></a>Issue 7</h4> 352 <blockquote> 353 <p>Austin Group Interpretations 1003.1-2001 #017, #021, and #088 are applied, clarifying the standard output for the <b>-k</b> 354 option when <i>LANG</i> is not set or is an empty string.</p> 355 <p>SD5-XCU-ERN-97 is applied, updating the SYNOPSIS.</p> 356 <p>POSIX.1-2008, Technical Corrigendum 1, XCU/TC1-2008/0097 [291] is applied.</p> 357 <p>POSIX.1-2008, Technical Corrigendum 2, XCU/TC2-2008/0114 [941] is applied.</p> 358 </blockquote> 359 <h4 class="mansect"><a name="tag_20_68_25" id="tag_20_68_25"></a>Issue 8</h4> 360 <blockquote> 361 <p>Austin Group Defect 1122 is applied, changing the description of <i>NLSPATH .</i></p> 362 <p>Austin Group Defect 1262 is applied, changing the EXAMPLES section.</p> 363 </blockquote> 364 <div class="box"><em>End of informative text.</em></div> 365 <hr> 366 <p> </p> 367 <a href="#top"><span class="topOfPage">return to top of page</span></a><br> 368 <hr size="2" noshade> 369 <center><font size="2">UNIX® is a registered Trademark of The Open Group.<br> 370 POSIX™ is a Trademark of The IEEE.<br> 371 Copyright © 2001-2024 The IEEE and The Open Group, All Rights Reserved<br> 372 [ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href= 373 "../functions/contents.html">XSH</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../xrat/contents.html">XRAT</a> 374 ]</font></center> 375 <hr size="2" noshade> 376 <div class="NAVHEADER"> 377 <table summary="Header navigation table" class="nav" width="100%" border="0" cellpadding="0" cellspacing="0"> 378 <tr class="nav"> 379 <td class="nav" width="15%" align="left" valign="bottom"><a href="../utilities/ln.html" accesskey="P"><<< 380 Previous</a></td> 381 <td class="nav" width="70%" align="center" valign="bottom"><a href="contents.html">Home</a></td> 382 <td class="nav" width="15%" align="right" valign="bottom"><a href="../utilities/localedef.html" accesskey="N">Next 383 >>></a></td> 384 </tr> 385 </table> 386 <hr align="left" width="100%"></div> 387 </body> 388 </html>