/usr/bin/bash: Difference between revisions

Line 2,182: Line 2,182:


;exit [n]
;exit [n]
:Cause  the  shell to exit with a status of n.  If n is omitted, the exit status is that of the last command executed.  A trap on EXIT is executed before the shell terminates.
:nが省略された場合、終了ステータスは最後に実行されたコマンドのステータスとなる。 EXIT のトラップは、シェルが終了する前に実行される。


;<nowiki>export [-fn] [name[=word]] ...</nowiki>
;<nowiki>export [-fn] [name[=word]] ...</nowiki>
;export -p
;export -p
:The supplied names are marked for automatic export to the environment of subsequently executed commands.  If the -f option is given, the names refer to functions.  If no names are given, or if the -p option is supplied, a list of  names  of  all  exported  variables  is printed.  The -n option  causes the export property to be removed from each name.  If a variable name is followed by =word, the value of the variable is set to word.  export  returns an exit status of 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オプションが指定された場合、名前は関数を参照する。 名前が指定されない場合、または -p オプションが指定された場合は、エクスポートされたすべての変数名のリストが表示される。 -n オプションを指定すると、各名称からエクスポート・プロパティが削除される。 変数名の後に=wordが続くと、その変数の値がwordに設定される。exportは、無効なオプションに遭遇するか、名前の1つが有効なシェル変数名でないか、-fに関数でない名前が指定されない限り、終了ステータス0を返す。


;<nowiki>fc [-e ename] [-lnr] [first] [last]</nowiki>
;<nowiki>fc [-e ename] [-lnr] [first] [last]</nowiki>
;<nowiki>fc -s [pat=rep] [cmd]</nowiki>
;<nowiki>fc -s [pat=rep] [cmd]</nowiki>
:The first form selects a range of commands from first to last from the  history  list  and displays  or  edits and re-executes them.  First and last may be specified as a string (to locate the last command beginning with that string) or as a number (an index into the history  list, where a negative number is used as an offset from the current command number). When listing, a first or last of 0 is equivalent to -1 and -0 is equivalent to the current command  (usually  the fc command); otherwise 0 is equivalent to -1 and -0 is invalid.  If last is not specified, it is set to the current command for listing (so that ``fc -l -10'' prints the last 10 commands) and to first otherwise.  If first is not specified, it is set to the previous command for editing and -16 for listing.
:最初の形式は、履歴リストから最初のコマンドから最後のコマンドまでの範囲を選択し、それらを表示または編集して再実行する。 firstとlastは、文字列(その文字列で始まる最後のコマンドを探す)または数値(履歴リストへのインデックス、負の数は現在のコマンド番号からのオフセットとして使われる)で指定することができる。リストを表示する場合、firstまたはlastに0を指定すると-1となり、-0を指定すると現在のコマンド(通常はfcコマンド)となる。 もしlastが指定されなければ、リストアップのために現在のコマンドに設定され (``fc -l -10'' は最後の10個のコマンドを表示する)、そうでなければfirstに設定される。 もしfirstが指定されなければ、編集の場合は前のコマンドに、リストアップの場合は-16に設定される。


:The -n option suppresses the command numbers when listing.  The -r option reverses the order  of the commands.  If the -l option is given, the commands are listed on standard output.  Otherwise, the editor given by ename is invoked on a file containing those commands. If  ename  is not given, the value of the FCEDIT variable is used, and the value of EDITOR if FCEDIT is not set.  If neither variable is set, vi is used.  When editing is  complete, the edited commands are echoed and executed.
:-nオプションは、一覧表示時にコマンド番号を表示しない。 -rオプションはコマンドの順序を逆にする。 -lオプションを指定すると、コマンドは標準出力にリストされる。 それ以外の場合、enameで指定されたエディタが、それらのコマンドを含む ファイルに対して起動される。enameが与えられていない場合、変数FCEDITの値が使われ、 FCEDITが設定されていない場合、EDITORの値が使われる。 どちらの変数も設定されていなければ、viが使われる。 編集が完了すると、編集されたコマンドがエコーされて実行される。


:In  the second form, command is re-executed after each instance of pat is replaced by rep. Command is interpreted the same as first above.  A  useful  alias  to  use  with  this  is ``r="fc -s"'',  so  that  typing ``r cc'' runs the last command beginning with ``cc'' and typing ``r'' re-executes the last command.
:第二の形式では、patの各インスタンスがrepに置き換えられた後、コマンドが再実行される。コマンドは上記の最初のものと同じように解釈される。 r="fc-s"」と入力すると、「cc」で始まる最後のコマンドが実行され、「r」と入力すると最後のコマンドが再実行される。


:If the first form is used, the return value is 0 unless an invalid option  is  encountered or  first  or  last specify history lines out of range.  If the -e option is supplied, the return value is the value of the last command executed or failure if an error occurs  with the  temporary file of commands.  If the second form is used, the return status is that of the command re-executed, unless cmd does not specify a valid history line, in  which  case fc returns failure.
:最初の形式を使用した場合、無効なオプションに遭遇するか、最初または最後の指定行が範囲外でない限り、戻り値は0である。 eオプションが与えられた場合、戻り値は最後に実行されたコマンドの値か、コマンドの一時ファイルでエラーが発生した場合は失敗となる。 2番目の形式が使われた場合、cmdが有効なヒストリ行を指定しない限り、戻り値は再実行されたコマンドのステータスとなり、その場合fcは失敗を返す。


;fg [jobspec]
;fg [jobspec]
:Resume jobspec in the foreground, and make it the current job.  If jobspec is not present, the shell's notion of the current job is used.  The return value is that  of  the  command placed  into  the  foreground, or failure if run when job control is disabled or, when run with job control enabled, if jobspec does not specify a valid job or jobspec  specifies  a job that was started without job control.
:jobspec をフォアグラウンドで再開し、現在のジョブにする。 jobspec が存在しない場合、シェルの現在のジョブの概念が使用される。 戻り値は、フォアグラウンドに配置されたコマンドの値であり、ジョブ制御が無効なときに実行された場合は失敗となる。ジョブ制御が有効なときに実行された場合は、jobspecが有効なジョブを指定していないか、ジョブ制御なしで開始されたジョブを指定している。


;getopts optstring name [arg ...]
;getopts optstring name [arg ...]
:getopts  is  used  by shell procedures to parse positional parameters.  optstring contains the option characters to be recognized; if a character is followed by a colon, the  option is  expected  to  have an argument, which should be separated from it by white space.  The colon and question mark characters may not be used as option characters.  Each time it  is invoked,  getopts  places the next option in the shell variable name, initializing name if it does not exist, and the index of the next argument to be processed  into  the  variable OPTIND.  OPTIND  is  initialized  to  1 each time the shell or a shell script is invoked. When an option requires an argument, getopts places that argument into  the  variable OPTARG.  The shell  does not reset OPTIND automatically; it must be manually reset between multiple calls to getopts within the same shell invocation if a new set of  parameters  is to be used.
:optstringには、認識すべきオプション文字が含まれる。ある文字の後にコロンが続く場合、そのオプションは引数を持つことが期待され、その引数は空白で区切らなければならない。 コロンとクエスチョンマークはオプション文字としては使えない。 getoptsは起動されるたびに、次のオプションをシェル変数nameに入れ、nameが存在しない場合は初期化し、次に処理される引数のインデックスを変数OPTINDに入れる。 OPTINDは、シェルまたはシェルスクリプトが起動されるたびに1に初期化される。オプションが引数を必要とする場合、getopts はその引数を変数 OPTARG に入れる。 シェルは OPTIND を自動的にリセットしないので、新しいパラメータセットを使用する場合は、同じシェル呼び出し内で getopts を複数回呼び出す間に手動でリセットする必要がある。


:When  the  end  of  options is encountered, getopts exits with a return value greater than zero.  OPTIND is set to the index of the first non-option argument, and name is set to ?.
:オプションの終了に遭遇すると、getoptsは0より大きい戻り値で終了する。 OPTINDには、最初の非オプション引数のインデックスが設定され、 nameには?をセットする。


:getopts normally parses the positional parameters, but if more arguments are  supplied  as arg values, getopts parses those instead.
:getoptsは通常、位置パラメータを解析するが、arg値としてさらに引数が与えられると、getoptsはそれらを代わりに解析する。


:getopts  can  report  errors in two ways.  If the first character of optstring is a colon, silent error reporting is used.  In normal operation, diagnostic messages are printed when invalid  options  or  missing option arguments are encountered.  If the variable OPTERR is set to 0, no error messages will be displayed, even if the first character of optstring is not a colon.
:getoptsは2つの方法でエラーを報告することができる。 optstringの最初の文字がコロンの場合、サイレントエラー報告が使用される。 通常の操作では、無効なオプションやオプション引数の欠落に遭遇すると、診断メッセージが表示される。 変数 OPTERR 0 に設定すると、optstring の最初の文字がコロンでなくても、エラーメッセージは表示されない。


:If an invalid option is seen, getopts places ? into name and, if not silent, prints an error message and unsets OPTARG.  If getopts is silent, the option character found is placed in OPTARG and no diagnostic message is printed.
:無効なオプションが見つかった場合、getopts は name に ? を入れ、無音でなければエラーメッセージを表示して OPTARG の設定を解除する。 getopts が沈黙している場合、見つかったオプション文字は OPTARG に置かれ、診断メッセージは出力されない。


:If  a  required  argument  is not found, and getopts is not silent, a question mark (?) is placed in name, OPTARG is unset, and a diagnostic  message  is  printed.   If  getopts  is silent,  then  a  colon  (:) is  placed in name and OPTARG is set to the option character found.
:必須引数が見つからず、getoptsがサイレントでない場合、nameにクエスチョンマーク(?  getoptsが無音の場合、nameにコロン(:)が置かれ、OPTARGには見つかったオプション文字が設定される。


:getopts returns true if an option, specified or unspecified, is found.  It  returns  false if the end of options is encountered or an error occurs.
:getoptsは、指定または未指定のオプションが見つかれば真を返す。 オプションの末尾にぶつかったり、エラーが発生した場合は偽を返す。


;<nowiki>hash [-lr] [-p filename] [-dt] [name]</nowiki>
;<nowiki>hash [-lr] [-p filename] [-dt] [name]</nowiki>
:Each  time hash is invoked, the full pathname of the command name is determined by searching the directories in $PATH and remembered.  Any previously-remembered pathname  is  discarded.  If the -p option is supplied, no path search is performed, and filename is used as the full filename of the command.  The -r option causes the shell to forget all  remembered locations.  The -d option causes the shell to forget the remembered location of each name.  If the -t option is supplied, the full pathname to which each name corresponds  is printed.  If multiple name arguments are supplied with -t, the name is printed before the hashed full pathname.  The -l option causes output to be displayed in a format that may be reused  as input.  If no arguments are given, or if only -l is supplied, information about remembered commands is printed.  The return status is true unless a name is not  found  or an invalid option is supplied.
:hashが起動されるたびに、コマンド名のフルパス名が$PATH内のディレクトリを検索して決定され、記憶される。 以前に記憶されたパス名は破棄される。 -pオプションが与えられると、パス検索は行われず、 filenameがコマンドの完全なファイル名として使われる。 -rオプションを付けると、シェルは記憶していた場所をすべて忘れる。 -dオプションを指定すると、シェルは各名称の記憶された場所を忘れる。 -t オプションを指定すると、各名前が対応する完全なパス名が表示される。 複数の name 引数が -t とともに与えられた場合、 name はハッシュされたフルパス名の前に出力される。 -lオプションを指定すると、入力として再利用できる形式で出力が表示される。 引数が与えられないか、-lだけが与えられると、記憶されたコマンドに関する情報が表示される。 名前が見つからないか、無効なオプションが与えられない限り、戻り値は真である。


;<nowiki>help [-dms] [pattern]</nowiki>
;<nowiki>help [-dms] [pattern]</nowiki>