|
|
Line 2,363: |
Line 2,363: |
|
| |
|
| ;<nowiki>read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]</nowiki> | | ;<nowiki>read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p prompt] [-t timeout] [-u fd] [name ...]</nowiki> |
| :One line is read from the standard input, or from the file descriptor fd supplied as an argument to the -u option, split into words as described above under Word Splitting, and the first word is assigned to the first name, the second word to the second name, and so on. If there are more words than names, the remaining words and their intervening delimiters are assigned to the last name. If there are fewer words read from the input stream than names, the remaining names are assigned empty values. The characters in IFS are used to split the line into words using the same rules the shell uses for expansion (described above under Word Splitting). The backslash character (\) may be used to remove any special meaning for the next character read and for line continuation. Options, if supplied, have the following meanings: | | :標準入力、または-uオプションの引数として与えられたファイル・ディスクリプタfdから1行が読み込まれ、上記の「単語の分割」で説明したように単語に分割され、最初の単語が最初の名前に、2番目の単語が2番目の名前に、といった具合に割り当てられる。 単語が名前より多い場合は、残りの単語とその間の区切り文字が最後の名前に割り当てられる。 入力ストリームから読み込まれた単語の数が名前の数より少ない場合、残りの名前には空の値が割り当てられる。 IFSの文字は、シェルが展開に使用するのと同じ規則を使用して行を単語に分割する ために使用される(上記の「単語の分割」で説明)。 バックスラッシュ文字( \)は、次に読み込まれる文字と行の継続のための特別な意味を取り除くために使用される。 オプションが与えられた場合、以下の意味を持つ: |
| :;-a aname | | :;-a aname |
| ::The words are assigned to sequential indices of the array variable aname, starting at 0. aname is unset before any new values are assigned. Other name arguments are ignored. | | ::新しい値が代入される前に、anameはアンセットされる。 他の名前引数は無視される。 |
| :;-d delim | | :;-d delim |
| ::The first character of delim is used to terminate the input line, rather than newline. If delim is the empty string, read will terminate a line when it reads a NUL character. | | ::delimの最初の文字は、改行ではなく、入力行を終了するために使われる。 delimが空文字列の場合、readはNUL文字を読んだ時点で行を終了する。 |
| :;-e | | :;-e |
| ::If the standard input is coming from a terminal, readline (see READLINE above) is used to obtain the line. Readline uses the current (or default, if line editing was not previously active) editing settings, but uses Readline's default filename completion. | | ::標準入力がターミナルからの場合、行を取得するためにreadline(上記の[[#READLINE|READLINE ]]を参照)が使用される。 Readlineは、現在の(または行編集が以前にアクティブでなかった場合はデフォルトの)編集設定を使用するが、Readlineのデフォルトのファイル名補完を使用する。 |
| :;-i text | | :;-i text |
| ::If readline is being used to read the line, text is placed into the editing buffer before editing begins. | | ::行の読み取りにreadlineが使われている場合、テキストは編集が始まる前に編集バッファに置かれる。 |
| :;-n nchars | | :;-n nchars |
| ::read returns after reading nchars characters rather than waiting for a complete line of input, but honors a delimiter if fewer than nchars characters are read before the delimiter. | | ::readは、入力の完全な行を待つのではなく、nchars文字を読んだ後に戻るが、区切り文字の前にnchars文字より少ない文字が読み込まれた場合は、区切り文字を尊重する。 |
| :;-N nchars | | :;-N nchars |
| ::read returns after reading exactly nchars characters rather than waiting for a complete line of input, unless EOF is encountered or read times out. Delimiter characters encountered in the input are not treated specially and do not cause read to return until nchars characters are read. The result is not split on the characters in IFS; the intent is that the variable is assigned exactly the characters read (with the exception of backslash; see the -r option below). | | ::readは、EOFに遭遇するかreadがタイムアウトしない限り、入力の完全な行を待つのではなく、正確にnchars文字を読んだ後に戻る。 入力中の区切り文字は特別に扱われず、nchars文字が読み込まれるまでreadが戻ることはない。 その意図は、読み込まれた文字がそのまま変数に代入されることである(バックスラッシュを除く。) |
| :;-p prompt | | :;-p prompt |
| ::Display prompt on standard error, without a trailing newline, before attempting to read any input. The prompt is displayed only if input is coming from a terminal. | | ::入力を読み込む前に、標準エラーにプロンプトを表示する。 プロンプトは、入力がターミナルから来た場合にのみ表示される。 |
| :;-r | | :;-r |
| ::Backslash does not act as an escape character. The backslash is considered to be part of the line. In particular, a backslash-newline pair may not then be used as a line continuation. | | ::バックスラッシュはエスケープ文字としては機能しない。 バックスラッシュは行の一部とみなされる。 特に、バックスラッシュと改行のペアを行の続きとして使用してはならない。 |
| :;-s | | :;-s |
| ::Silent mode. If input is coming from a terminal, characters are not echoed. | | ::サイレントモード。 端末からの入力の場合、文字はエコーされない。 |
| :;-t timeout | | :;-t timeout |
| ::Cause read to time out and return failure if a complete line of input (or a specified number of characters) is not read within timeout seconds. timeout may be a decimal number with a fractional portion following the decimal point. This option is only effective if read is reading input from a terminal, pipe, or other special file; it has no effect when reading from regular files. If read times out, read saves any partial input read into the specified variable name. If timeout is 0, read returns immediately, without trying to read any data. The exit status is 0 if input is available on the specified file descriptor, non-zero otherwise. The exit status is greater than 128 if the timeout is exceeded. | | ::timeout秒以内に入力の完全な行(または指定された文字数)が読み込まれなかった場合、readをタイムアウトさせ、失敗を返すようにする。timeoutには、小数点以下の端数を含む10進数を指定することができる。 このオプションは、readがターミナル、パイプ、その他の特殊なファイルから入力を読み込む場合にのみ有効で、通常のファイルから読み込む場合には効果がない。 readがタイムアウトした場合、readは読み込んだ入力の一部を指定した変数名に保存する。 タイムアウトが0の場合、readはデータの読み込みを試みずに直ちに戻る。 終了ステータスは、指定されたファイル記述子で入力が利用可能であれば0、そうでなければ0以外である。 タイムアウトを超えると、終了ステータスは128より大きくなる。 |
| :;-u fd | | :;-u fd |
| ::Read input from file descriptor fd. | | ::ファイルディスクリプタfdから入力を読み込む。 |
|
| |
|
| :If no names are supplied, the line read, without the ending delimiter but otherwise unmodified, is assigned to the variable REPLY. The exit status is zero, unless end-of-file is encountered, read times out (in which case the status is greater than 128), a variable assignment error (such as assigning to a readonly variable) occurs, or an invalid file descriptor is supplied as the argument to -u. | | :名前が与えられない場合、読み込まれた行は、終端デリミタなしで、それ以外は変更されずに、変数 REPLY に代入される。 終了ステータスは、ファイル終了に遭遇するか、読み込みがタイムアウトするか(この場合、ステータスは128より大きくなる)、変数代入エラー(読み取り専用変数への代入など)が発生するか、無効なファイル記述子が-uの引数として与えられない限り、0である。 |
|
| |
|
| ;<nowiki>readonly [-aAf] [-p] [name[=word] ...]</nowiki> | | ;<nowiki>readonly [-aAf] [-p] [name[=word] ...]</nowiki> |
| :The given names are marked readonly; the values of these names may not be changed by subsequent assignment. If the -f option is supplied, the functions corresponding to the names are so marked. The -a option restricts the variables to indexed arrays; the -A option restricts the variables to associative arrays. If both options are supplied, -A takes precedence. If no name arguments are given, or if the -p option is supplied, a list of all readonly names is printed. The other options may be used to restrict the output to a subset of the set of readonly names. The -p option causes output to be displayed in a format that may be reused as input. If a variable name is followed by =word, the value of the variable is set to word. The return status is 0 unless an invalid option is encountered, one of the names is not a valid shell variable name, or -f is supplied with a name that is not a function. | | :指定された名前には読み取り専用マークが付けられ、以後の代入によってこれらの名前の値が変更されることはない。-f オプションを指定すると、その名前に対応する関数がそのようにマークされる。 -aオプションは変数を添字配列に制限し、-Aオプションは変数を連想配列に制限する。 両方のオプションが指定された場合は、-Aが優先される。 name 引数が与えられていない場合、または -p オプションが与えられている場合は、すべての読み取り専用名のリストが表示される。 他のオプションを使って、出力を読み取り専用名のサブセットに制限することができる。 pオプションを指定すると、入力として再利用できる形式で出力が表示される。 変数名の後に=wordが続くと、その変数の値がwordに設定される。 無効なオプションに遭遇した場合、名前の1つが有効なシェル変数名でない場合、または -f に関数でない名前が指定された場合を除き、戻り値は 0 である。 |
|
| |
|
| ;<nowiki>return [n]</nowiki> | | ;<nowiki>return [n]</nowiki> |
| :Causes a function to stop executing and return the value specified by n to its caller. If n is omitted, the return status is that of the last command executed in the function body. If return is executed by a trap handler, the last command used to determine the status is the last command executed before the trap handler. If return is executed during a DEBUG trap, the last command used to determine the status is the last command executed by the trap handler before return was invoked. If return is used outside a function, but during execution of a script by the . (source) command, it causes the shell to stop executing that script and return either n or the exit status of the last command executed within the script as the exit status of the script. If n is supplied, the return value is its least significant 8 bits. The return status is non-zero if return is supplied a non-numeric argument, or is used outside a function and not during execution of a script by . or source. Any command associated with the RETURN trap is executed before execution resumes after the function or script. | | :関数の実行を停止し、nで指定された値を呼び出し元に返す。 nが省略された場合、returnのステータスは、関数本体内で最後に実行されたコマンドのステータスとなる。return がトラップハンドラによって実行される場合、ステータスを決定するために使用される最後のコマンドは、トラップハンドラの前に実行された最後のコマンドである。 returnがDEBUGトラップ中に実行された場合、ステータスを決定するために使用される最後のコマンドは、returnが呼び出される前にトラップハンドラによって実行された最後のコマンドである。 returnが関数の外で、.(ソース)コマンドによるスクリプトの実行中に使用された場合、そのスクリプトの実行をシェルに停止させ、nまたはスクリプト内で最後に実行されたコマンドの終了ステータスのいずれかをスクリプトの終了ステータスとして返す。 n が指定された場合、戻り値はその最下位 8 ビットである。 returnに数値以外の引数が指定された場合、または.やsourceによるスクリプトの実行中ではなく関数の外部で使用された場合、戻り値は0以外のステータスになる。RETURNトラップに関連付けられたコマンドは、関数またはスクリプトの実行後に実行が再開される前に実行される。 |
|
| |
|
| ;<nowiki>set [--abefhkmnptuvxBCEHPT] [-o option-name] [arg ...]</nowiki> | | ;<nowiki>set [--abefhkmnptuvxBCEHPT] [-o option-name] [arg ...]</nowiki> |