/usr/bin/getopt: Difference between revisions

Line 65: Line 65:


== OUTPUT ==
== OUTPUT ==
      Output is generated for each element described in the previous section.  Output is done in the  same
出力は、前のセクションで説明した各要素に対して生成される。 出力は、非オプション・パラメーターを除き、入力で指定された要素と同じ順序で行われる。 出力は、互換(引用符なし)モードで行うこともできるし、引数や非オプション パラメータ内の空白文字やその他の特殊文字を保持するように行うこともできる(引用符を参照)。 出力がシェルスクリプトで処理されるとき、それは(ほとんどのシェル言語でshiftコマンドを使用して)1つずつ処理することができる個別の要素で構成されているように見える。 これはunquotedモードでは不完全である、 要素が空白や特殊文字を含むと、予期しない場所で分割されることがあるからだ。
      order  as  the elements are specified in the input, except for non-option parameters.  Output can be
      done in compatible (unquoted) mode, or in such way that  whitespace  and  other  special  characters
      within  arguments  and  non-option  parameters are preserved (see QUOTING).  When the output is pro‐
      cessed in the shell script, it will seem to be composed of distinct elements that can  be  processed
      one  by  one  (by  using  the shift command in most shell languages).  This is imperfect in unquoted
      mode, as elements can be split at unexpected places if they contain whitespace  or  special  charac‐
      ters.


      If  there  are problems parsing the parameters, for example because a required argument is not found
必須引数が見つからない、またはオプションが認識されないなど、パラメータの解析に問題がある場合、標準エラー出力にエラーが報告され、問題のある要素の出力は行われず、ゼロ以外のエラーステータスが返される。
      or an option is not recognized, an error will be reported on stderr, there will be no output for the
      offending element, and a non-zero error status is returned.


      For  a  short  option, a single '-' and the option character are generated as one parameter.  If the
短いオプションの場合、1つの '-' とオプション文字が1つのパラメータとして生成される。 オプションに引数がある場合、次のパラメータが引数になる。 オプションが引数を取るが何も見つからなかった場合、次のパラメータが生成されるが、クォートモードでは空であり、クォートされていない (互換性のある) モードでは 2 番目のパラメータは生成されない。 他の多くの '''getopt'''(1) 実装はオプション引数をサポートしていないことに注意。
      option has an argument, the next parameter will be the argument.  If the option  takes  an  optional
      argument, but none was found, the next parameter will be generated but be empty in quoting mode, but
      no second parameter will be generated in unquoted (compatible) mode.  Note that many other getopt(1)
      implementations do not support optional arguments.


      If  several short options were specified after a single '-', each will be present in the output as a
複数の短いオプションが単一の '-' の後に指定された場合、 それぞれが独立したパラメータとして出力される。
      separate parameter.


      For a long option, '--' and the full option name are generated as one parameter.  This is  done  re‐
長いオプションの場合、'--' と完全なオプション名が 1 つのパラメータとして生成される。 これは、オプションが省略されているか、入力で単一の '-' で指定されているかに関係なく行われる。 引数は短いオプションと同様に扱われる。
      gardless  whether the option was abbreviated or specified with a single '-' in the input.  Arguments
      are handled as with short options.


      Normally, no non-option parameters output is generated until all options and  their  arguments  have
通常、すべてのオプションとその引数が生成されるまで、 オプション以外のパラメータ出力は生成されない。 その後、'--'が1つのパラメータとして生成され、 その後に非オプション・パラメータが見つかった順に、 それぞれ別のパラメータとして生成される。 短いオプション文字列の最初の文字が '-' だった場合のみ、 非オプション・パラメータの出力は、入力で見つかった場所に生成される (これは、'''SYNOPSIS''' の最初の書式が使われている場合はサポートされない。 この場合、'-' '+' の前にあるものはすべて無視される)
      been generated.  Then '--' is generated as a single parameter, and after it the non-option parame‐
      ters in the order they were found, each as a separate parameter.  Only if the first character of the
      short options string was a '-', non-option parameter output is generated at the place they are found
      in the input (this is not supported if the first format of the SYNOPSIS is used; in  that  case  all
      preceding occurrences of '-' and '+' are ignored).


==QUOTING==
==QUOTING==