.\" .\" Japanese Version Copyright (c) 2001-2003 Yuichi SATO .\" all rights reserved. .\" Translated Tue 11 Jan 1994 .\" by NetBSD jman proj. .\" Updated Sun Jan 14 04:46:37 JST 2001 .\" by Yuichi SATO .\" Updated & Modified Sun Mar 2 15:11:49 JST 2003 .\" by Yuichi SATO .\" .\"WORD: parse 解析する .\"WORD: interpret 解釈する .\" .TH GETOPT 1 "May 31, 1997" Linux "" .\"O .SH NAME .SH 名前 .\"O getopt \- parse command options (enhanced) getopt \- コマンドの引き数を解析する (拡張版) .\"O .SH SYNOPSIS .SH 書式 .BR getopt " optstring parameters" .BR getopt " [options] [" \-\- "] optstring parameters" .BR getopt " [options] " \-o | \-\-options " optstring [options] [" \-\- "] parameters" .\"O .SH DESCRIPTION .SH 説明 .\"O .B getopt .\"O is used to break up .\"O .RI ( parse ) .\"O options in command lines for easy parsing by .\"O shell procedures, and to check for legal options. .\"O It uses the .\"O .SM GNU .\"O .BR getopt (3) .\"O routines to do this. .B getopt は、シェル手続きで簡単に解析できるように、 コマンドラインのオプションを分解 .RI ( 解析 ) するために使われる。 また、正しいオプションであるかを調べるためにも使われる。 これを行うために .SM GNU .BR getopt (3) ルーチンが使われる。 .\"O The parameters .\"O .B getopt .\"O is called with can be divided into two parts: options .\"O which modify the way getopt will parse .\"O .RI ( options .\"O and .\"O .I \-o|\-\-options optstring .\"O in the .\"O .BR SYNOPSIS), .\"O and the parameters which are to be .\"O parsed .\"O .RI ( parameters .\"O in the .\"O .BR SYNOPSIS). .B getopt を呼び出すときに使われたパラメータは、 2 つの部分に分けることができる: getopt の解析動作を変更するオプション .RB ( 「書式」 セクションの .I options と .IR "\-o|\-\-options optstring" ) と、解析されるパラメータ .RB ( 「書式」 セクションの .IR parameters ) である。 .\"O The second part will start at the first non\-option parameter .\"O that is not an option argument, or after the first occurrence of .\"O .RB ` \-\- '. .\"O If no .\"O .RB ` \-o ' .\"O or .\"O .RB ` \-\-options ' .\"O option is found in the first part, the first .\"O parameter of the second part is used as the short options string. 第 2 部分は、 最初のオプションではないパラメータ (オプション引き数ではないもの) の後か、 最初の .B ` \-\- ' の後から始まる。 第 1 部分に .RB ` \-o ' または .RB ` \-\-options ' オプションが見つからない場合、 第 2 部分の最初のパラメータは 短い形式のオプション文字列として使われる。 .\"O If the environment variable .\"O .B GETOPT_COMPATIBLE .\"O is set, or if its first parameter .\"O is not an option (does not start with a .\"O .RB ` \- ', .\"O this is the first format in the .\"O .BR SYNOPSIS), .\"O .B getopt .\"O will generate output that is compatible with that of other versions of .\"O .BR getopt (1). 環境変数 .B GETOPT_COMPATIBLE が設定された場合、 または最初のパラメータがオプションでなかった場合 .RB (` \- ' で始まっていない場合。 これは .B 「書式」 セクションの最初の形式である)、 .B getopt は他のバージョンの .BR getopt (1) と互換性のある出力を生成する。 .\"O It will still do parameter shuffling and recognize optional .\"O arguments (see section .\"O .B COMPATIBILITY .\"O for more information). この場合でも、パラメータの並べ替えを行い、オプション引き数を認識する (詳細は .B 「互換性」 セクションを参照すること)。 .\"O Traditional implementations of .\"O .BR getopt (1) .\"O are unable to cope with whitespace and other (shell\-specific) special characters .\"O in arguments and non\-option parameters. 伝統的な .BR getopt (1) の実装では、引き数やオプションではないパラメータで 空白と他の (シェル特有の) 特殊文字を組み合わせて使うことができない。 .\"O To solve this problem, this .\"O implementation can generate .\"O quoted output which must once again be interpreted by the shell (usually .\"O by using the .\"O .B eval .\"O command). この問題を解決するため、 この実装ではクォートした出力を生成する。 この出力は、シェル (通常は .B eval コマンドが使われる) によって再び解析されなければならない。 .\"O This has the effect of preserving those characters, but .\"O you must call .\"O .B getopt .\"O in a way that is no longer compatible with other versions (the second .\"O or third format in the .\"O .BR SYNOPSIS). これにはクォートすべき文字列を保護するという効果があるが、 .B getopt を他のバージョンとは互換性のない方法 .RB ( 「書式」 セクションの 2, 3 番目の形式) で呼び出さなければならない。 .\"O To determine whether this enhanced version of .\"O .BR getopt (1) .\"O is installed, a special test option .\"O .RB ( \-T ) .\"O can be used. 拡張版の .BR getopt (1) がインストールされているかどうかを調べるには、特別なテストオプション .RB ( \-T ) を使うことができる。 .\"O .SH OPTIONS .SH オプション .IP "\-a, \-\-alternative" .\"O Allow long options to start with a single .\"O .RB ` - '. 長いオプションを 1 個の .RB ` \- ' で始めることができるようにする。 .IP "\-h, \-\-help" .\"O Output a small usage guide and exit succesfully. No other output is generated. ちょっとした使用ガイドを表示し、正常終了する。 それ以上は何も出力されない。 .IP "\-l, \-\-longoptions longopts" .\"O The long (multi\-character) options to be recognized. .\"O More than one option name .\"O may be specified at once, by separating the names with commas. This option .\"O may be given more than once, the .\"O .I longopts .\"O are cumulative. 認識させる長い (複数文字の) オプションを指定する。 2 つ以上のオプション名をコンマで区切って一度に指定できる。 このオプションは 2 回以上指定することができる。 .I longopts は交換可能である。 .\"O Each long option name .\"O in .\"O .I longopts .\"O may be followed by one colon to indicate it has a required argument,and by two colons to indicate it has an optional argument. .I longopts で指定されている長いオプション名の後に、1 個のコロンを続けることができる。 これは、そのオプションに引き数が必須であることを示す。 また、長いオプション名の後に 2 個のコロンを続けることもできる。 これは、そのオプションが引き数を取る場合もあることを示す。 .IP "\-n, \-\-name progname" .\"O The name that will be used by the .\"O .BR getopt (3) .\"O routines when it reports errors. Note that errors of .\"O .BR getopt (1) .\"O are still reported as coming from getopt. エラーが報告された場合に .BR getopt (3) ルーチンが使うプログラム名。 このオプションを指定しても、 .BR getopt (1) のエラーは getopt から発生したものとして表示される点に注意すること。 .IP "\-o, \-\-options shortopts" .\"O The short (one\-character) options to be recognized. If this options is not .\"O found, the first parameter of .\"O .B getopt .\"O that does not start with .\"O a .\"O .RB ` \- ' .\"O (and is not an option argument) is used as the short options string. 認識させる短い (1 文字の) オプションを指定する。 このオプションが指定されていない場合、 .B getopt の 1 個の .RB ` \- ' で始まっていない最初のパラメータ (かつ、オプションの引き数でないもの) が 短いオプションの文字列として使われる。 .\"O Each short option character .\"O in .\"O .I shortopts .\"O may be followed by one colon to indicate it has a required argument, .\"O and by two colons to indicate it has an optional argument. .I shortopts に指定されている短いオプション文字の後に、1 個のコロンを続けることができる。 これは、そのオプションに引き数が必須であることを示す。 また、長いオプション名の後に 2 個のコロンを続けることもできる。 これは、そのオプションが引き数を取る場合もあることを示す。 .\"O The first character of shortopts may be .\"O .RB ` + ' .\"O or .\"O .RB ` \- ' .\"O to influence the way .\"O options are parsed and output is generated (see section .\"O .B SCANNING MODES .\"O for details). オプションの解析法と出力の生成法を変更するために、 shortopts の最初の文字を .RB ` + ' または .RB ` \- ' にすることができる (詳細は .B 「スキャンモード」 セクションを参照すること)。 .IP "\-q, \-\-quiet" .\"O Disable error reporting by getopt(3). getopt(3) によるエラー表示をさせない。 .IP "\-Q, \-\-quiet\-output" .\"O Do not generate normal output. Errors are still reported by .\"O .BR getopt (3), .\"O unless you also use .\"O .IR \-q . 通常の出力を生成させない。 .IR \-q を指定しない限り、 .BR getopt (3) によってエラーが表示される。 .IP "\-s, \-\-shell shell" .\"O Set quoting conventions to those of shell. If no \-s argument is found, .\"O the .\"O .SM BASH .\"O conventions are used. Valid arguments are currently .\"O .RB ` sh ' .\"O .RB ` bash ', .\"O .RB ` csh ', .\"O and .\"O .RB ` tcsh '. 指定したシェルのクォート方法に設定する。 \-s オプションが指定されていない場合、 .SM BASH でのクォート方法が使われる。 指定可能な引き数は、現在のところ .RB ` sh ', .RB ` bash ', .RB ` csh ', .RB ` tcsh ' である。 .IP "\-u, \-\-unquoted" .\"O Do not quote the output. Note that whitespace and special (shell\-dependent) .\"O characters can cause havoc in this mode (like they do with other .\"O .BR getopt (1) .\"O implementations). 出力をクォートしない。 空白と (シェル依存の) 特殊文字は、(他の .BR getopt (1) の実装と同じように) このモードでは大混乱を引き起こす。 .IP "\-T \-\-test" .\"O Test if your .\"O .BR getopt (1) .\"O is this enhanced version or an old version. This generates no output, .\"O and sets the error status to 4. Other implementations of .\"O .BR getopt (1), .\"O and this version if the environment variable .\"O .B GETOPT_COMPATIBLE .\"O is set, .\"O will return .\"O .RB ` \-\- ' .\"O and error status 0. .BR getopt (1) が拡張バージョンか古いバージョンかをテストする。 何も出力しないが、エラーステータスを 4 に設定する。 他の .BR getopt (1) の実装の場合や、このバージョンで環境変数 .B GETOPT_COMPATIBLE が設定されている場合、 .RB ` \-\- ' を返し、エラーステータスを 0 に設定する。 .IP "\-V, \-\-version" .\"O Output version information and exit succesfully. No other output is generated. バージョン情報を出力し、正常終了する。 それ以上は何も出力されない。 .\"O .SH PARSING .SH 解析 .\"O This section specifies the format of the second part of the parameters of .\"O .B getopt .\"O (the .\"O .I parameters .\"O in the .\"O .BR SYNOPSIS ). このセクションでは .B getopt のパラメータの第 2 部分 .RB ( 「書式」 セクションの .IR parameters ) のフォーマットについて説明している。 .\"O The next section .\"O .RB ( OUTPUT ) .\"O describes the output that is .\"O generated. These parameters were typically the parameters a shell function .\"O was called with. 次のセクション .RB ( 出力 ) では生成される出力について説明している。 これらのパラメータは、一般に、シェル関数が呼ばれたときのパラメータである。 .\"O Care must be taken that each parameter the shell function was .\"O called with corresponds to exactly one parameter in the parameter list of .\"O .B getopt .\"O (see the .\"O .BR EXAMPLES ). .\"O All parsing is done by the GNU .\"O .BR getopt (3) .\"O routines. シェル関数が呼ばれたときの各パラメータが .B getopt のパラメータリストにある 1 つのパラメータに 厳密に対応している点に注意しなければならない .RB ( 「例」 セクションを参照すること)。 全ての解析が GNU .BR getopt (3) ルーチンで行われる。 .\"O The parameters are parsed from left to right. Each parameter is classified as a .\"O short option, a long option, an argument to an option, .\"O or a non\-option parameter. パラメータは左から右へ解析される。 各パラメータは、短いオプション・長いオプション・オプションへの引き数・ オプションではないパラメータに分類される。 .\"O A simple short option is a .\"O .RB ` \- ' .\"O followed by a short option character. If .\"O the option has a required argument, it may be written directly after the option .\"O character or as the next parameter (ie. separated by whitespace on the .\"O command line). If the .\"O option has an optional argument, it must be written directly after the .\"O option character if present. 簡単な短いオプションは、 .RB ` \- ' の後に短いオプション文字が続くものである。 オプションが引き数を必須としている場合、 引き数はオプション文字の直後に書くことができる。 (コマンドライン上で空白で区切られた) 次のパラメータとして書くこともできる。 オプションが引き数を取ることも取らないこともできる場合、 引き数が存在するならば、オプション文字の直後に書かなければならない。 .\"O It is possible to specify several short options after one .\"O .RB ` \- ', .\"O as long as all (except possibly the last) do not have required or optional .\"O arguments. (最後のオプションを除く) 全てのオプションが 必須の引き数もオプションとしての引き数も必要としない限り、 1 個の .RB ` \- ' の後に複数の短いオプションを指定することができる。 .\"O A long option normally begins with .\"O .RB ` \-\- ' .\"O followed by the long option name. 長いオプションは、通常 .RB ` \-\- ' の後に長いオプション名が続く。 .\"O If the option has a required argument, it may be written directly after .\"O the long option name, separated by .\"O .RB ` = ', .\"O or as the next argument (ie. separated by whitespace on the command line). オプションが引き数を必須としている場合、 .RB ` = ' で区切って長いオプション名の直後に書くことができる。 また、(コマンドライン上で空白で区切って) 次の引き数として書くこともできる。 .\"O If the option has an optional argument, it must .\"O be written directly after the long option name, separated by .\"O .RB ` = ', .\"O if present (if you add the .\"O .RB ` = ' .\"O but nothing behind it, it is interpreted .\"O as if no argument was present; this is a slight bug, see the .\"O .BR BUGS ). .\"O Long options may be abbreviated, as long as the abbreviation is not .\"O ambiguous. オプションが引き数を取ることも取らないこともできる場合、 引き数が存在するならば、 .RB ` = ' で区切って長いオプション名の直後に書かなければならない .RB (` = ' をオプションの後に書いたにも関らず、その後に何も指定しなかった場合、 引き数が存在しないものとして解釈される。 これはちょっとしたバグである。 .B 「バグ」 セクションを参照すること)。 長いオプションは、省略形が曖昧でない (他のオプションと区別がつく) 限り、 短く省略することができる。 .\"O Each parameter not starting with a .\"O .RB ` \- ', .\"O and not a required argument of .\"O a previous option, is a non\-option parameter. Each parameter after .\"O a .\"O .RB ` \-\- ' .\"O parameter is always interpreted as a non\-option parameter. .RB ` \- ' で始まらず、かつ前のオプションが必須としている引き数でもないパラメータは、 オプションではないパラメータである。 .RB ` \-\- ' パラメータの後にあるパラメータは、 オプションではないパラメータとして解釈される。 .\"O If the environment variable .\"O .B POSIXLY_CORRECT .\"O is set, or if the short .\"O option string started with a .\"O .RB ` + ', .\"O all remaining parameters are interpreted .\"O as non\-option parameters as soon as the first non\-option parameter is .\"O found. 環境変数 .B POSIXLY_CORRECT が設定されている場合、 または短いオプション文字列が .RB ` + ' で始まっている場合、 最初のオプションではないパラメータが見つかった時点で、 残りの全てのパラメータはオプションではないパラメータとして解釈される。 .\"O .SH OUTPUT .SH 出力 .\"O Output is generated for each element described in the previous section. .\"O Output is done .\"O in the same order as the elements are specified in the input, except .\"O for non\-option parameters. Output can be done in .\"O .I compatible .\"O .RI ( unquoted ) .\"O mode, or in such way that whitespace and other special characters within .\"O arguments and non\-option parameters are preserved (see .\"O .BR QUOTING ). 出力は前のセクションで説明した各要素に対して生成される。 出力は要素が入力で指定された順番で生成される。 ただし、オプションではないパラメータは例外である。 出力は .I 互換 .RI ( クォートされない ) モードで生成することができる。 また、引き数とオプションではないパラメータに含まれる空白と他の特殊文字を 保護するモードで出力することもできる .RB ( 「クォート」 セクションを参照すること)。 .\"O When the output is processed in the shell script, it will seem to be .\"O composed of distinct elements that can be processed one by one (by using the .\"O shift command in most shell languages). This is imperfect in unquoted mode, .\"O as elements can be split at unexpected places if they contain whitespace .\"O or special characters. 出力がシェルスクリプトで処理される場合、 その出力は別々の要素から構成されているようにみえる。 この要素は (大部分のシェル言語では shift コマンドを使って) 1 つ 1 つ処理できる。 この動作はクォートされないモードでは不完全である。 なぜなら、要素に空白や特殊文字があった場合、 要素が期待していない箇所で分割されてしまうからである。 .\"O If there are problems parsing the parameters, for example because a .\"O required argument is not found or an option is not recognized, an error .\"O will be reported on stderr, there will be no output for the offending .\"O element, and a non\-zero error status is returned. 必須とされる引き数が見つからない、またはオプションが認識されない、 といった原因でパラメータ解析に問題がある場合、 標準エラーにエラーが表示される。 このとき、不正な要素に対しては何も出力されず、 0 でないエラーステータスが返される。 .\"O For a short option, a single .\"O .RB ` \- ' .\"O and the option character are generated .\"O as one parameter. If the option has an argument, the next .\"O parameter will be the argument. If the option takes an optional argument, .\"O but none was found, the next parameter will be generated but be empty in .\"O quoting mode, .\"O but no second parameter will be generated in unquoted (compatible) mode. .\"O Note that many other .\"O .BR getopt (1) .\"O implemetations do not support optional arguments. 短いオプションに対して、出力として 1 個の .RB ` - ' とオプション文字が生成される。 オプションが引き数を取る場合、次のパラメータが引き数になる。 オプションが引き数を取っても取らなくてもよい場合に、 引き数が指定されていないと、 クォートモードでは次のパラメータが生成されるが空のパラメータになる。 この場合、クォートしない (互換) モードでは 2 番目のパラメータは生成されない。 他の多くの .BR getopt (1) の実装では、取っても取らなくてもよい引き数は サポートされていない点に注意すること。 .\"O If several short options were specified after a single .\"O .RB ` \- ', .\"O each will be present in the output as a separate parameter. 複数の短いオプションが 1 個の .RB ` \- ' の後に指定されている場合、 各オプションは区切られたパラメータとして出力に表示される。 .\"O For a long option, .\"O .RB ` \-\- ' .\"O and the full option name are generated as one .\"O parameter. This is done regardless whether the option was abbreviated or .\"O specified with a single .\"O .RB ` \- ' .\"O in the input. Arguments are handled as with short options. 長いオプションに対して、 .RB ` \-\- ' と完全なオプション名が 1 つのパラメータとして生成される。 「入力でオプションが略書きされている。 または、オプションが 1 個の .RB ` \- ' を使って指定されている。」ということに関らず、この動作をする。 引き数は短いオプションとして扱われる。 .\"O Normally, no non\-option parameters output is generated until all options .\"O and their arguments have been generated. Then .\"O .RB ` \-\- ' .\"O is generated as a .\"O single parameter, and after it the non\-option parameters in the order .\"O they were found, each as a separate parameter. 通常、全てのオプションとその引き数が出力に生成されるまで、 オプションではないパラメータは出力されない。 そして、1 個のパラメータとして .RB ` \-\- ' が生成される。 その後にオプションではないパラメータは、 見つかった順番で別々のパラメータとして生成される。 .\"O Only if the first character of the short options string was a .\"O .RB ` \- ', .\"O non\-option parameter output is generated at the place they are found in the .\"O input (this is not supported if the first format of the .\"O .B SYNOPSIS .\"O is used; in that case all preceding occurrences of .\"O .RB ` \- ' .\"O and .\"O .RB ` + ' .\"O are ignored). 短いオプション文字列の最初の文字が .RB ` \- ' である場合にのみ、 オプションではないパラメータは入力で見つかった位置で出力される (この動作は .B 「書式」 セクションの最初の形式が使われた場合にはサポートされない。 この場合、 .RB ` \- ' と .RB ` + ' が前に付く全てのパラメータが無視される)。 .\"O .SH QUOTING .SH クォート .\"O In compatible mode, whitespace or 'special' characters in arguments or .\"O non\-option parameters are not handled correctly. As the output is .\"O fed to the shell script, the script does not know how it is supposed to break .\"O the output into separate parameters. To circumvent this .\"O problem, this implementation offers quoting. The idea is that output .\"O is generated with quotes around each parameter. When this output is once .\"O again fed to the shell (usually by a shell .\"O .B eval .\"O command), it is split correctly into separate parameters. 互換モードでは、引き数やオプションではないパラメータにある 空白や「特殊」文字は正しく扱われない。 この出力はシェルスクリプトに与えられるので、 スクリプトは、出力をどのようにして個々のパラメータに 分割すべきなのかを知らない。 この問題を回避するため、この実装ではクォート機能を提供する。 これは、各パラメータをクォートして出力を生成する、という手法を取る。 この出力がもう一度シェル (通常はシェルの .B eval コマンド) に与えられた場合、 出力は個々のパラメータに正しく分割される。 .\"O Quoting is not enabled if the environment variable .\"O .B GETOPT_COMPATIBLE .\"O is set, if the first form of the .\"O .B SYNOPSIS .\"O is used, or if the option .\"O .RB ` \-u ' .\"O is found. 環境変数 .B GETOPT_COMPATIBLE が設定された場合・ .B 「書式」 セクションの最初の形式が使われた場合・ .RB ` \-u ' オプションが指定された場合、クォートは行われない。 .\"O Different shells use different quoting conventions. You can use the .\"O .RB ` \-s ' .\"O option to select the shell you are using. The following shells are .\"O currently supported: .\"O .RB ` sh ', .\"O .RB ` bash ', .\"O .RB ` csh ' .\"O and .\"O .RB ` tcsh '. .\"O Actually, only two `flavors' are distinguished: sh\-like quoting conventions .\"O and csh\-like quoting conventions. Chances are that if you use another shell .\"O script language, one of these flavors can still be used. クォートの規則はシェルごとに異なる。 使用しているシェルを選択するために .RB ` \-s ' オプションを使うことができる。 以下のシェルで正しく機能する: .RB ` sh ', .RB ` bash ', .RB ` csh ' , .RB ` tcsh '. 実際には、2 つの「方式」に分類される: sh 式のクォート規則と csh 式のクォート規則である。 他のシェルスクリプト言語を使っている場合でも、 これらの方式のどちらかが使える可能性がある。 .\"O .SH "SCANNING MODES" .SH スキャンモード .\"O The first character of the short options string may be a .\"O .RB ` \- ' .\"O or a .\"O .RB ` + ' .\"O to indicate a special scanning mode. If the first calling form .\"O in the .\"O .B SYNOPSIS .\"O is used they are ignored; the environment variable .\"O .B POSIXLY_CORRECT .\"O is still examined, though. 特殊なスキャンモードであることを示すために、 短いオプションの最初の文字を .RB ` \- ' または .RB ` + ' にすることができる。 .B 「書式」 セクションの最初の呼び出し形式が使われた場合、これは無視される。 しかし、環境変数 .B POSIXLY_CORRECT が指定されているかどうかは調べられる。 .\"O If the first character is .\"O .RB ` + ', .\"O or if the environment variable .\"O .B POSIXLY_CORRECT .\"O is set, parsing stops as soon as the first non\-option parameter .\"O (ie. a parameter that does not start with a .\"O .RB ` \- ') .\"O is found that .\"O is not an option argument. The remaining parameters are all interpreted as .\"O non\-option parameters. 最初の文字が .RB ` + ' の場合、または環境変数 .B POSIXLY_CORRECT が設定されている場合、オプションではない最初のパラメータ (つまり、 .RB ` \- ' で始まっていないパラメータ) が オプション引き数でないと分かった時点で解析はストップする。 それ以降の全てのパラメータは、オプションではないパラメータとして解釈される。 .\"O If the first character is a .\"O .RB ` \- ', .\"O non\-option parameters are outputed at the place where they are found; in normal .\"O operation, they are all collected at the end of output after a .\"O .RB ` \-\- ' .\"O parameter has been generated. Note that this .\"O .RB ` \-\- ' .\"O parameter is still generated, but it will always be the last parameter in .\"O this mode. 最初の文字が .RB ` \- ' の場合、オプションではない引き数は見つかった箇所で出力される。 通常の操作では、 .RB ` \-\- ' パラメータが生成された後で、最後にまとめて出力される。 この場合でも .RB ` \-\- ' パラメータは生成されるが、 通常このモードでは最後のパラメータになる点に注意すること。 .\"O .SH COMPATIBILITY .SH 互換性 .\"O This version of .\"O .BR getopt (1) .\"O is written to be as compatible as possible to .\"O other versions. Usually you can just replace them with this version .\"O without any modifications, and with some advantages. このバージョンの .BR getopt (1) は、出来るだけ他のバージョンと互換性があるように書かれた。 通常は他のバージョンを修正することなく、 このバージョンに置き換えることができる。 更に、いくつかの利点がある。 .\"O If the first character of the first parameter of getopt is not a .\"O .RB ` \- ', .\"O getopt goes into compatibility mode. It will interpret its first parameter as .\"O the string of short options, and all other arguments will be parsed. It .\"O will still do parameter shuffling (ie. all non\-option parameters are outputed .\"O at the end), unless the environment variable .\"O .B POSIXLY_CORRECT .\"O is set. getopt の最初のパラメータの最初の文字が .RB ` \- ' でない場合、getopt は互換モードになる。 最初のパラメータは短いオプションの文字列として解釈され、 他の全ての引き数が解析される。 この場合でも、環境変数 .B POSIXLY_CORRECT が設定されていない限り、パラメータの並べ替えを行う (つまり、オプションではない全てのパラメータが最後に出力される)。 .\"O The environment variable .\"O .B GETOPT_COMPATIBLE .\"O forces .\"O .B getopt .\"O into compatibility mode. Setting both this environment variable and .\"O .B POSIXLY_CORRECT .\"O offers 100% compatibility for `difficult' programs. Usually, though, .\"O neither is needed. 環境変数 .B GETOPT_COMPATIBLE は .B getopt を強制的に互換モードにする。 この環境変数と .B POSIXLY_CORRECT の両方を設定すると、「難しい」プログラムのために 100% の互換性を提供する。 しかし、通常はどちらも設定する必要がない。 .\"O In compatibility mode, leading .\"O .RB ` \- ' .\"O and .\"O .RB ` + ' .\"O characters in the short options string are ignored. 互換モードでは、短いオプション文字列の最初に付く .RB ` \- ' と .RB ` + ' は無視される。 .\"O .SH RETURN CODES .SH リターンコード .\"O .B getopt .\"O returns error code .\"O .B 0 .\"O for succesful parsing, .\"O .B 1 .\"O if .\"O .BR getopt (3) .\"O returns errors, .\"O .B 2 .\"O if it does not understand its own parameters, .\"O .B 3 .\"O if an internal error occurs like out\-of\-memory, and .\"O .B 4 .\"O if it is called with .\"O .BR \-T . 解析に成功した場合、 .B getopt はエラーコード .B 0 を返す。 .BR getopt (3) がエラーを返した場合は .B 1 を返す。 パラメータが理解できなかった場合は .B 2 を返す。 メモリが足りない (out\-of\-memory) といった内部エラーの場合は .B 3 を返す。 .BR \-T オプションを付けて呼び出された場合は .B 4 を返す。 .\"O .SH EXAMPLES .SH 例 .\"O Example scripts for (ba)sh and (t)csh are provided with the .\"O .BR getopt (1) .\"O distribution, and are optionally installed in .\"O .B /usr/local/lib/getopt .\"O or .\"O .BR /usr/lib/getopt . (ba)sh と (t)csh での使用例のスクリプトは、 .BR getopt (1) ディストリビューションで提供されている。 これらはオプションとして .B /usr/local/lib/getopt または .B /usr/lib/getopt にインストールされている。 .\"O .SH ENVIRONMENT .SH 環境変数 .IP POSIXLY_CORRECT .\"O This environment variable is examined by the .\"O .BR getopt (3) .\"O routines. この環境変数は .BR getopt (3) ルーチンで調べられる。 .\"O If it is set, parsing stops as soon as a parameter .\"O is found that is not an option or an option argument. All remaining .\"O parameters are also interpreted as non\-option parameters, regardless .\"O whether they start with a .\"O .RB ` \- '. これが設定されている場合、パラメータがオプションまたは オプション引き数でないと分かった時点で解析は停止する。 それ以降の全てのパラメータは、 .RB ` \- ' で始まっているかどうかに関係なく、 オプションではないパラメータとして解釈される。 .IP GETOPT_COMPATIBLE .\"O Forces .\"O .B getopt .\"O to use the first calling format as specified in the .\"O .BR SYNOPSIS . .B getopt に対して強制的に .B 「書式」 セクションの最初の呼び出し形式を使わせる。 .\"O .SH BUGS .SH バグ .\"O .BR getopt (3) .\"O can parse long options with optional arguments that are given an empty optional .\"O argument (but can not do this for short options). This .\"O .BR getopt (1) .\"O treats optional arguments that are empty as if they were not present. .BR getopt (3) は、引き数を取っても取らなくてもよい長いオプションを解析できる (ただし、短いオプションの場合は解析できない)。 この .BR getopt (1) は、オプション引き数が指定されていない場合、それが存在しないものとして扱う。 .\"O The syntax if you do not want any short option variables at all is .\"O not very intuitive (you have to set them explicitely to the empty .\"O string). 短いオプション変数を全く使いたくない場合、 書式は全く直感的でないものになる (明示的に空の文字列に設定する必要がある)。 .\"O .SH AUTHOR .SH 著者 Frodo Looijaard .\"O .SH "SEE ALSO" .SH 関連項目 .BR getopt (3), .BR bash (1), .BR tcsh (1).