📄 utilconv.html
字号:
arguments depicted in the<b>SYNOPSIS</b>sections are mandatory requirementsplaced on portable applications.The use of conflicting mutually exclusivearguments produces undefined results,unless a utility description specifies otherwise.When an option is shown without the<b>[ ]</b>brackets, it means that option is required for that version of the<b>SYNOPSIS</b>.However, it is not required to be the first argument,as shown in the example above, unless otherwise stated.<p>The use of<i>undefined</i>for conflicting argument usageand for repeated usage of the same optionis meant to prevent portable applicationsfrom using conflicting arguments or repeated options,unless specifically allowed, as is the case with<i><a href="../xcu/ls.html">ls</a></i>(which allows simultaneous, repeated use of the<b>-C</b>,<b>-l</b>and<b>-1</b>options).Many historical implementations will tolerate this usage,choosing either the first or the last applicable argument,and this tolerance may continue, but portable applicationscannot rely upon it.(Other implementations may choose to print usage messages instead.)<p>The use of<i>undefined</i>for conflicting argument usage also allowsan implementation to make reasonable extensions to utilitieswhere the implementor considersmutually exclusive options according to the <b>XCU</b> specification to have asensible meaning and result.<p><li>Ellipses (...) are used to denote that one or more occurrences ofan option or operand are allowed.When an option or an operandfollowed by ellipses is enclosed in brackets, zero or moreoptions or operands can be specified.The forms:<pre><code>utility_name -f <i>option_argument</i>...<b>[</b><i>operand</i>...<b>]</b>utility_name <b>[</b>-g <i>option_argument</i><b>]</b>...<b>[</b><i>operand</i>...<b>]</b></code></pre>indicate that multiple occurrences of the option and itsoption-argument preceding the ellipsesare valid, with semantics as indicated in the<b>OPTIONS</b>section of the utility.(See also Guideline 11 in<xref href=usg><a href="#tag_009_002">Utility Syntax Guidelines</a></xref>.)In the first example, each option-argument requires a preceding<b>-f</b>and at least one<b>-f</b> <i>option_argument</i>must be given.<p>The <b>XCU</b> specification does not define the result of a utility when anoption-argument or operand is not followed by ellipses andthe application specifies more than one of that option-argument or operand.This allows animplementation to define valid (although non-standard) behaviourfor the utility when more than one such option or operand are specified.<p><li>When the synopsis line is too long to be printed on a single line inthe <b>XCU</b> specification, the indented lines following the initial line arecontinuation lines.An actual use of the command would appear on a single logical line.<p></ol><h3><a name = "tag_009_002"><a name="usg">Utility Syntax Guidelines</a> </a></h3><xref type="2" name="usg"></xref>The following guidelines are established for the naming ofutilities and for the specification of options,option-arguments and operands.The<i><a href="../xsh/getopt.html">getopt()</a></i>function in the <b>XSH</b> specification assists utilitiesin handling options and operands that conform to these guidelines.<p>Operands and option-arguments can contain characters not specified inthe portable character set.<p>The guidelines are intended to provide guidance to theauthors of future utilities, such as those written specificto a local system or that are to be components ofa larger application.Some of the standard utilities do notconform to all of these guidelines; in those cases, the<b>OPTIONS</b>sections describe the deviations.<dl compact><dt><b>Guideline 1:</b><dd>Utility names should be between two and nine characters, inclusive.<dt><b>Guideline 2:</b><dd>Utility names should include lower-case letters(the<b>lower</b>character classification)and digits onlyfrom the portable character set.Guidelines 1 and 2 are offered as guidance for localesusing Latin alphabets.No recommendations are made by this specification setconcerning utility naming in other locales.In the <b>XCU</b> specification, <a href="../xcu/chap2.html#tag_001_009_001"><b>Simple Commands</b> </a>,it is further stated that a command used inthe XSI Shell Command Language cannot be named with a trailing colon.<dt><b>Guideline 3:</b><dd>Each option name should be a single alphanumeric character(the<b>alnum</b>character classification)from the portable character set.Multi-digit options are not allowed.Instances of historical utilities that used themhave been marked <b>LEGACY</b> in the <b>XCU</b> specification, with the numbersbeing changed from option names to option-arguments.<dt><b>Guideline 4:</b><dd>All options should be preceded by the "-" delimiter character.<dt><b>Guideline 5:</b><dd>Options without option-arguments should beaccepted when grouped behind one "-" delimiter.<dt><b>Guideline 6:</b><dd>Each option and option-argument should be a separate argument,except as noted in<xref href=utilarg><a href="#tag_009_001">Utility Argument Syntax</a></xref>,item (2).<dt><b>Guideline 7:</b><dd>Option-arguments should not be optional.<dt><b>Guideline 8:</b><dd>When multiple option-arguments are specified to follow a single option,they should be presented as a single argument, using commaswithin that argument orblank characterswithin that argument to separate them.It is up to the utility to parse a comma-separated list itselfbecause<i><a href="../xsh/getopt.html">getopt()</a></i>just returns a single string.This situation was retained so that certain historicalutilities would not violate the guidelines.Applications preparing for international use should be awareof an occasional problem with comma-separated lists:in some locales, the comma is used as the radix character.Thus, if an application is preparing operands for a utilitythat expects a comma-separated list, it should avoid generatingnon-integer values through one of the means that is influencedby setting the<i>LC_NUMERIC</i>variable (such as<i><a href="../xcu/awk.html">awk</a></i>,<i><a href="../xcu/bc.html">bc</a></i>,<i><a href="../xcu/printf.html">printf</a></i>or<i><a href="../xsh/printf.html">printf()</a></i>).<dt><b>Guideline 9:</b><dd>All options should precede operands on the command line.<dt><b>Guideline 10:</b><dd>The argument--should be accepted as a delimiter indicating the end of options.Any following arguments should be treated as operands, even if theybegin with the "-" character.The--argument should not be used as an option or as an operand.Applications calling any utility with a first operand starting with-should usually specify--,as indicated by Guideline 10, to mark the end of the options.This is true even if the<b>SYNOPSIS</b>in the <b>XCU</b> specification does not specify any options;implementations may provide options as extensions to the <b>XCU</b> specification.The standard utilities that do not support Guideline 10 indicate that factin the<b>OPTIONS</b>section of the utility description.<dt><b>Guideline 11:</b><dd>The order of different options relative to one another should not matter,unless the options are documented asmutually exclusive and such an option is documented tooverride any incompatible options preceding it.If an option that has option-arguments is repeated,the option and option-argument combinations should beinterpreted in the order specified on the command line.The order of repeated options that also have option-arguments may besignificant; therefore, such options are required to beinterpreted in the order that they are specified.The<i><a href="../xcu/make.html">make</a></i>utility is an instance of a historical utility thatuses repeated options in which the order is significant.Multiple files are specified by giving multiple instances of the<b>-f</b>option, for example:<pre><code>make -f common_header -f specific_rules target</code></pre><dt><b>Guideline 12:</b><dd>The order of operands may matter andposition-related interpretations shouldbe determined on a utility-specific basis.<dt><b>Guideline 13:</b><dd>For utilities that use operands to represent filesto be opened for either reading or writing, the "-"operand should be used only to mean standard input(or standard output when it is clear from contextthat an output file is being specified).Guideline 13 does not imply that all of the standard utilitiesautomatically accept the operand "-"to mean standard input or output, nor does it specifythe actions of the utility upon encountering multiple "-" operands.It simply says that, by default, "-"operands are not used for other purposesin the file reading or writing (but not when using<i><a href="../xsh/stat.html">stat()</a></i>,<i><a href="../xsh/unlink.html">unlink()</a></i>,<i><a href="../xcu/touch.html">touch</a></i>,and so forth) utilities.All information concerning actual treatment of the "-"operand is found in the individual utility sections.</dl><p>The utilities in the <b>XCU</b> specification thatclaim conformance to these guidelineswere written as if the term<i>should</i>imposed a specific requirement on their interfaceand applications and users can rely on the behaviour stated here;the Guidelines are rules for the standard utilities thatclaim conformance to them.On some systems, the utilities willaccept usage in violation of these guidelines for backwardcompatibility as well as accepting the required form.<p>It is recommended that all futureutilities and applications use these guidelines to enhanceuser portability.The fact that some historical utilities could not be changed(to avoid breaking existing applications) should not deter thisfuture goal.</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -