|
|
Line 9: |
Line 9: |
|
| |
|
| ==DESCRIPTION== | | ==DESCRIPTION== |
| getopt is used to break up (parse) options in command lines for easy parsing by shell procedures,
| | getoptは、コマンドラインのオプションを分割(パース)して、シェル手続きで簡単にパースできるようにしたり、有効なオプションかどうかをチェックしたりするのに使われる。 そのために'''[https://manpages.debian.org/bookworm/manpages-dev/getopt.3.en.html GNU getopt]'''(3)ルーチンを使用する。 |
| and to check for valid options. It uses the GNU getopt(3) routines to do this.
| |
|
| |
|
| The parameters getopt is called with can be divided into two parts: options which modify the way
| | getopt が呼び出されるパラメータは 2 つの部分に分けられる。 getopt がパースする方法を変更するオプション ('''SYNOPSIS''' 内のオプションと optstring) と、パースされるパラメータ ('''SYNOPSIS''' 内のパラメータ) である。 2番目の部分は、オプション引数ではない最初のパラメータ、 または '--' が最初に出現した後のパラメータから始まる。 最初の部分で'-o'または'--options'オプションが見つからない場合、 2番目の部分の最初のパラメーターが短いオプション文字列として使われる。 |
| getopt will do the parsing (the options and the optstring in the SYNOPSIS), and the parameters which
| |
| are to be parsed (parameters in the SYNOPSIS). The second part will start at the first non-option
| |
| parameter that is not an option argument, or after the first occurrence of '--'. If no '-o' or
| |
| '--options' option is found in the first part, the first parameter of the second part is used as the
| |
| short options string.
| |
|
| |
|
| If the environment variable GETOPT_COMPATIBLE is set, or if the first parameter is not an option
| | 環境変数 '''GETOPT_COMPATIBLE''' が設定されている場合、 または最初のパラメータがオプションでない場合 ('''SYNOPSIS''' の最初の書式である '-' で始まらない場合)、 getopt は他のバージョンの '''getopt'''(1) と互換性のある出力を生成する。 パラメータシャッフルを行い、オプション引数を認識する (詳細については '''COMPATIBILITY''' を参照のこと)。 |
| (does not start with a '-', the first format in the SYNOPSIS), getopt will generate output that is
| |
| compatible with that of other versions of getopt(1). It will still do parameter shuffling and rec‐
| |
| ognize optional arguments (see section COMPATIBILITY for more information).
| |
|
| |
|
| Traditional implementations of getopt(1) are unable to cope with whitespace and other (shell-spe‐
| | 従来の '''getopt'''(1) の実装は、引数やオプション以外のパラメータに含まれる空白文字やその他の (シェル固有の) 特殊文字に対処できない。 この問題を解決するために、この実装では引用符で囲まれた出力を生成することができる。 これはこれらの文字を保持する効果があるが、他のバージョンと互換性のない方法('''SYNOPSIS'''の2番目か3番目の形式)でgetoptを呼び出さなければならない。 この拡張バージョンの getopt(1) がインストールされているかどうかを調べるには、特別なテストオプション (-T) を使用する。 |
| cific) special characters in arguments and non-option parameters. To solve this problem, this im‐
| |
| plementation can generate quoted output which must once again be interpreted by the shell (usually
| |
| by using the eval command). This has the effect of preserving those characters, but you must call
| |
| getopt in a way that is no longer compatible with other versions (the second or third format in the
| |
| SYNOPSIS). To determine whether this enhanced version of getopt(1) is installed, a special test op‐
| |
| tion (-T) can be used.
| |
|
| |
|
| == OPTIONS == | | == OPTIONS == |