/usr/bin/bash: Difference between revisions

Line 1,210: Line 1,210:


== EXIT STATUS ==
== EXIT STATUS ==
      The exit status of an executed command is the value returned by the waitpid system call or equiv‐
実行されたコマンドの終了ステータスは、waitpidシステムコールまたは同等の関数が返す値である。 終了ステータスは0から255の間であるが、以下で説明するように、シェルは特別に125以上の値を使用することがある。 シェル組み込み関数と複合コマンドの終了ステータスもこの範囲に制限される。 特定の状況下では、シェルは特定の失敗モードを示すために特別な値を使用する。
      alent function.  Exit statuses fall between 0 and 255, though, as explained below, the shell  may
      use values above 125 specially.  Exit statuses from shell builtins and compound commands are also
      limited to this range.  Under certain circumstances, the shell will use special values  to  indi‐
      cate specific failure modes.


      For  the  shell's purposes, a command which exits with a zero exit status has succeeded.  An exit
シェルの目的上、終了ステータスが0で終了するコマンドは成功したことになる。 ゼロの終了ステータスは成功を示す。 ゼロ以外の終了ステータスは失敗を示す。 致命的シグナルNでコマンドが終了する場合、bashは128+Nの値を終了ステータスとして使用する。
      status of zero indicates success.  A non-zero exit status indicates failure.  When a command ter‐
      minates on a fatal signal N, bash uses the value of 128+N as the exit status.


      If a command is not found, the child process created to execute it returns a status of 127.  If a
コマンドが見つからない場合、そのコマンドを実行するために作成された子プロセスは127のステータスを返す。 コマンドは見つかったが実行できない場合、ステータスは126となる。
      command is found but is not executable, the return status is 126.


      If a command fails because of an error during  expansion  or  redirection,  the  exit  status  is
展開中またはリダイレクト中のエラーによりコマンドが失敗した場合、終了ステータスは0より大きくなる。
      greater than zero.


      Shell  builtin commands return a status of 0 (true) if successful, and non-zero (false) if an er‐
シェル組み込みコマンドは、成功すれば0(真)のステータスを返し、実行中にエラーが発生すれば0以外(偽)のステータスを返す。 すべての組み込みコマンドは、不正な使用(通常は無効なオプションや引数の欠落)を示す終了ステータス2を返す。
      ror occurs while they execute.  All builtins return an exit status of 2 to indicate incorrect us‐
      age, generally invalid options or missing arguments.


      Bash  itself  returns the exit status of the last command executed, unless a syntax error occurs,
Bash自身は、構文エラーが発生しない限り、最後に実行したコマンドの終了ステータスを返し、その場合はゼロ以外の値で終了する。 以下のexit組み込みコマンドも参照のこと。
      in which case it exits with a non-zero value.  See also the exit builtin command below.


== SIGNALS ==
== SIGNALS ==