|
|
Line 1,141: |
Line 1,141: |
|
| |
|
| == SIMPLE COMMAND EXPANSION == | | == SIMPLE COMMAND EXPANSION == |
| When a simple command is executed, the shell performs the following expansions, assignments, and
| | 単純なコマンドが実行されると、シェルは以下の展開、代入、リダイレクションを左から順に実行する。 |
| redirections, from left to right, in the following order.
| |
|
| |
|
| 1. The words that the parser has marked as variable assignments (those preceding the command
| | #パーサーが変数代入としてマークした単語(コマンド名の前にあるもの)とリダイレクションは、後の処理のために保存される。 |
| name) and redirections are saved for later processing.
| | #変数代入やリダイレクションでない単語は展開される。 展開後も単語が残っている場合、最初の単語はコマンド名とみなされ、それ以降の単語は引数となる。 |
| | #リダイレクションは上記の[[#REDIRECTION|REDIRECTION ]]の説明に従って実行される。 |
| | #各変数代入の=の後のテキストは、変数に代入される前に、チルダ展開、パラメータ展開、コマンド置換、算術展開、引用符除去を受ける。 |
|
| |
|
| 2. The words that are not variable assignments or redirections are expanded. If any words
| | コマンド名の結果がない場合、変数への代入は現在のシェル環境に影響する。 そうでなければ、変数は実行されたコマンドの環境に追加され、現在のシェル環境には影響しない。 代入のいずれかが読み取り専用変数に値を代入しようとした場合、エラーが発生し、コマンドは0以外のステータスで終了する。 |
| remain after expansion, the first word is taken to be the name of the command and the re‐
| |
| maining words are the arguments.
| |
|
| |
|
| 3. Redirections are performed as described above under REDIRECTION.
| | コマンド名の結果が得られない場合、リダイレクションが実行されるが、現在のシェル環境には影響しない。 リダイレクション・エラーは、コマンドをゼロ以外のステータスで終了させる。 |
|
| |
|
| 4. The text after the = in each variable assignment undergoes tilde expansion, parameter ex‐
| | 展開後にコマンド名が残っている場合、以下の説明に従って実行が進められる。 そうでなければ、コマンドは終了する。 展開のいずれかにコマンド置換が含まれていた場合、コマンドの終了ステータスは、最後に実行されたコマンド置換の終了ステータスになる。 コマンド置換がなかった場合、コマンドの終了ステータスは0である。 |
| pansion, command substitution, arithmetic expansion, and quote removal before being as‐
| |
| signed to the variable.
| |
| | |
| If no command name results, the variable assignments affect the current shell environment. Oth‐
| |
| erwise, the variables are added to the environment of the executed command and do not affect the
| |
| current shell environment. If any of the assignments attempts to assign a value to a readonly
| |
| variable, an error occurs, and the command exits with a non-zero status.
| |
| | |
| If no command name results, redirections are performed, but do not affect the current shell envi‐
| |
| ronment. A redirection error causes the command to exit with a non-zero status.
| |
| | |
| If there is a command name left after expansion, execution proceeds as described below. Other‐
| |
| wise, the command exits. If one of the expansions contained a command substitution, the exit
| |
| status of the command is the exit status of the last command substitution performed. If there
| |
| were no command substitutions, the command exits with a status of zero.
| |
|
| |
|
| == COMMAND EXECUTION == | | == COMMAND EXECUTION == |