|
|
(8 intermediate revisions by the same user not shown) |
Line 85: |
Line 85: |
|
| |
|
| ==SCANNING MODES== | | ==SCANNING MODES== |
| The first character of the short options string may be a '-' or a '+' to indicate a special scanning
| | 短いオプション文字列の最初の文字は、特別なスキャンモードを示すために '-'または'+'にすることができる。 '''SYNOPSIS'''の最初の呼び出し形式が使われる場合、それらは無視される。 |
| mode. If the first calling form in the SYNOPSIS is used they are ignored; the environment variable
| |
| POSIXLY_CORRECT is still examined, though.
| |
|
| |
|
| If the first character is '+', or if the environment variable POSIXLY_CORRECT is set, parsing stops
| | 最初の文字が'+'の場合、または環境変数'''POSIXLY_CORRECT'''が設定されている場合、 オプション引数でない最初のパラメータ(すなわち、'-'で始まらないパラメータ)が 見つかり次第、解析は停止する。 残りのパラメータは、すべて非オプション・パラメータとして解釈される。 |
| as soon as the first non-option parameter (i.e., a parameter that does not start with a '-') is
| |
| found that is not an option argument. The remaining parameters are all interpreted as non-option
| |
| parameters.
| |
|
| |
|
| If the first character is a '-', non-option parameters are outputted at the place where they are
| | 最初の文字が'-'の場合、非オプション・パラメータは見つかった場所に出力される。 通常の操作では、'--'パラメータが生成された後、それらはすべて出力の最後に集められる。 この'--'パラメーターも生成されるが、 このモードでは常に最後のパラメーターとなることに注意。 |
| found; in normal operation, they are all collected at the end of output after a '--' parameter has
| |
| been generated. Note that this '--' parameter is still generated, but it will always be the last
| |
| parameter in this mode.
| |
|
| |
|
| ==COMPATIBILITY== | | ==COMPATIBILITY== |
| This version of getopt(1) is written to be as compatible as possible to other versions. Usually you
| | このバージョンの '''getopt'''(1) は、他のバージョンと可能な限り互換性があるように書かれている。 通常、何も変更することなくこのバージョンと置き換えることができ、いくつかの利点もある。 |
| can just replace them with this version without any modifications, and with some advantages.
| |
|
| |
|
| If the first character of the first parameter of getopt is not a '-', getopt goes into compatibility
| | getopt の最初のパラメータの最初の文字が '-' でない場合、 getopt は互換モードに入る。 getoptは最初のパラメータを短いオプションの文字列として解釈し、他のすべての引数は解析される。 環境変数'''POSIXLY_CORRECT'''が設定されていない限り、パラメータのシャッフルは行われる(つまり、オプション以外のパラメータはすべて最後に出力される)。 |
| mode. It will interpret its first parameter as the string of short options, and all other arguments
| |
| will be parsed. It will still do parameter shuffling (i.e., all non-option parameters are output at
| |
| the end), unless the environment variable POSIXLY_CORRECT is set.
| |
|
| |
|
| The environment variable GETOPT_COMPATIBLE forces getopt into compatibility mode. Setting both this
| | 環境変数'''GETOPT_COMPATIBLE'''は、getoptを強制的に互換モードにする。 この環境変数と'''POSIXLY_CORRECT'''の両方を設定すると、「難しい」プログラムに対して100%の互換性を提供する。 しかし、通常はどちらも必要ない。 |
| environment variable and POSIXLY_CORRECT offers 100% compatibility for 'difficult' programs. Usu‐
| |
| ally, though, neither is needed.
| |
|
| |
|
| In compatibility mode, leading '-' and '+' characters in the short options string are ignored.
| | 互換モードでは、短いオプション文字列の先頭の '-' と '+' は無視される。 |
|
| |
|
| ==RETURN CODES== | | ==RETURN CODES== |
| getopt returns error code 0 for successful parsing, 1 if getopt(3) returns errors, 2 if it does not
| | getoptは、解析に成功した場合はエラーコード0を返し、'''[https://manpages.debian.org/bookworm/manpages-dev/getopt.3.en.html getopt]'''(3)がエラーを返した場合は1を返し、自身のパラメータを理解していない場合は2を返し、メモリ不足などの内部エラーが発生した場合は3を返し、-T付きで呼び出された場合は4を返す。 |
| understand its own parameters, 3 if an internal error occurs like out-of-memory, and 4 if it is
| |
| called with -T.
| |
|
| |
|
| ==EXAMPLES== | | ==EXAMPLES== |
| Example scripts for (ba)sh and (t)csh are provided with the getopt(1) distribution, and are in‐
| | '''(ba)sh'''と'''(t)csh'''のスクリプト例は、'''getopt'''(1)ディストリビューションで提供されており、<u>/usr/share/doc/util-linux/getopt/</u>ディレクトリにインストールされている。 |
| stalled in /usr/share/doc/util-linux/getopt/ directory.
| |
|
| |
|
| ==ENVIRONMENT== | | ==ENVIRONMENT== |
| POSIXLY_CORRECT
| | ;POSIXLY_CORRECT |
| This environment variable is examined by the getopt(3) routines. If it is set, parsing stops
| | :この環境変数は '''[https://manpages.debian.org/bookworm/manpages-dev/getopt.3.en.html getopt]'''(3) ルーチンで調べられる。 この環境変数が設定されている場合、オプションでもオプション引数でもないパラメータが見つかると、すぐに解析が停止する。 残りのすべてのパラメータも、'-' で始まるかどうかに関係なく、非オプションパラメータとして解釈される。 |
| as soon as a parameter is found that is not an option or an option argument. All remaining
| |
| parameters are also interpreted as non-option parameters, regardless whether they start with
| |
| a '-'.
| |
|
| |
|
| GETOPT_COMPATIBLE
| | ;GETOPT_COMPATIBLE |
| Forces getopt to use the first calling format as specified in the SYNOPSIS.
| | :'''getopt'''は、'''SYNOPSIS'''で指定された最初の呼び出しフォーマットを強制的に使用する。 |
|
| |
|
| ==BUGS== | | ==BUGS== |
| getopt(3) can parse long options with optional arguments that are given an empty optional argument
| | '''[https://manpages.debian.org/bookworm/manpages-dev/getopt.3.en.html getopt]'''(3) は、空のオプション引数を与えられたオプション引数を持つ長いオプションを解析することができる (しかし、短いオプションに対してはこれを行うことができない)。 この '''getopt'''(1) は、空のオプション引数は存在しないものとして扱う。 |
| (but cannot do this for short options). This getopt(1) treats optional arguments that are empty as
| |
| if they were not present.
| |
|
| |
|
| The syntax if you do not want any short option variables at all is not very intuitive (you have to
| | 短いオプション変数がまったく必要ない場合の構文は、あまり直感的ではない (明示的に空文字列に設定しなければならない)。 |
| set them explicitly to the empty string).
| |
|
| |
|
| ==AUTHOR== | | ==AUTHOR== |
| Frodo Looijaard ⟨frodo@frodo.looijaard.name⟩
| | Frodo Looijaard ⟨frodo@frodo.looijaard.name⟩ |
|
| |
|
| ==SEE ALSO== | | ==SEE ALSO== |
| bash(1), tcsh(1), getopt(3)
| | '''[[/usr/bin/bash|bash]]''', '''[[/usr/bin/tcsh|tcsh]]''', '''[https://manpages.debian.org/bookworm/manpages-dev/getopt.3.en.html getopt]'''(3) |
|
| |
|
| ==AVAILABILITY== | | ==AVAILABILITY== |
| The getopt command is part of the util-linux package and is available from Linux Kernel Archive
| | The getopt command is part of the util-linux package and is available from Linux Kernel Archive ⟨https://www.kernel.org/pub/linux/utils/util-linux/⟩. |
| ⟨https://www.kernel.org/pub/linux/utils/util-linux/⟩.
| |
|
| |
|
| == External link == | | == External link == |