|
|
(4 intermediate revisions by the same user not shown) |
Line 1,868: |
Line 1,868: |
|
| |
|
| === Word Designators === | | === Word Designators === |
| Word designators are used to select desired words from the event. A : separates the event specification from the word designator. It may be omitted if the word designator begins with a ^, $, *, -, or %. Words are numbered from the beginning of the line, with the first word being denoted by 0 (zero). Words are inserted into the current line separated by single spaces.
| | 単語指定子は、イベントから必要な単語を選択するために使用される。 は、イベントの指定と単語指示子を区切る。 単語指定子が^、$、*、-、%で始まる場合は省略できる。 単語は行頭から順に番号付けされ、最初の単語は0(ゼロ)で示される。 単語は、現在の行に半角スペースで区切って挿入される。 |
|
| |
|
| ;0 (zero) | | ;0 (zero) |
| :The zeroth word. For the shell, this is the command word. | | :番目の単語。 シェルでは、これはコマンドワードである。 |
| ;n | | ;n |
| :The nth word. | | :The nth word. |
| ;^ | | ;^ |
| :The first argument. That is, word 1. | | :最初の引数。 つまり単語1である。 |
| ;$ | | ;$ |
| :The last word. This is usually the last argument, but will expand to the zeroth word if there is only one word in the line. | | :最後の単語。 これは通常最後の引数だが、行に単語が1つしかない場合は0番目の単語に展開される。 |
| ;% | | ;% |
| :The first word matched by the most recent `?string?' search, if the search string begins with a character that is part of a word. | | :検索文字列が単語の一部である文字で始まっている場合、直近の `?string?' 検索でマッチした最初の単語。 |
| ;x-y | | ;x-y |
| :A range of words; `-y' abbreviates `0-y'. | | :'-y'は'0-y'を省略したものである。 |
| ;* | | ;* |
| :All of the words but the zeroth. This is a synonym for `1-$'. It is not an error to use * if there is just one word in the event; the empty string is returned in that case. | | :0番目以外のすべての単語。 これは `1-$' と同意語である。 その場合は空文字列が返される。 |
| ;x* | | ;x* |
| :Abbreviates x-$. | | :Abbreviates x-$. |
| ;x- | | ;x- |
| :Abbreviates x-$ like x*, but omits the last word. If x is missing, it defaults to 0. | | :x*のようにx-$を省略するが、最後の単語は省略する。 xがない場合、デフォルトは0になる。 |
|
| |
|
| If a word designator is supplied without an event specification, the previous command is used as the event.
| | イベント指定なしで単語指定子を与えた場合、前のコマンドがイベントとして使用される。 |
|
| |
|
| === Modifiers === | | === Modifiers === |
| After the optional word designator, there may appear a sequence of one or more of the following modifiers, each preceded by a `:'. These modify, or edit, the word or words selected from the history event.
| | オプションの単語指示子の後には、それぞれ`:'で始まる1つ以上の修飾子が現れる。 これらは、履歴イベントから選択された単語を修正する。 |
|
| |
|
| ;h | | ;h |
| :Remove a trailing filename component, leaving only the head. | | :末尾のファイル名コンポーネントを削除し、先頭だけを残す。 |
| ;t | | ;t |
| :Remove all leading filename components, leaving the tail. | | :ファイル名の先頭をすべて削除し、末尾を残す。 |
| ;r | | ;r |
| :Remove a trailing suffix of the form .xxx, leaving the basename. | | :.xxx 形式の末尾のサフィックスを削除し、ベース名を残す。 |
| ;e | | ;e |
| :Remove all but the trailing suffix. | | :末尾の接尾辞以外はすべて削除する。 |
| ;p | | ;p |
| :Print the new command but do not execute it. | | :新しいコマンドを表示するが、実行はしない。 |
| ;q | | ;q |
| :Quote the substituted words, escaping further substitutions. | | :置換された単語を引用し、それ以上の置換を避ける。 |
| ;x | | ;x |
| :Quote the substituted words as with q, but break into words at blanks and newlines. The q and x modifiers are mutually exclusive; the last one supplied is used. | | :qと同様に置換された単語を引用するが、空白と改行で単語を区切る。 q修飾子とx修飾子は互いに排他的であり、最後に与えられたものが使われる。 |
| ;s/old/new/ | | ;s/old/new/ |
| :Substitute new for the first occurrence of old in the event line. Any character may be used as the delimiter in place of /. The final delimiter is optional if it is the last character of the event line. The delimiter may be quoted in old and new with a single backslash. If & appears in new, it is replaced by old. A single backslash will quote the &. If old is null, it is set to the last old substituted, or, if no previous history substitutions took place, the last string in a !?string[?] search. If new is null, each matching old is deleted. | | :イベント行で最初に出現するoldをnewに置き換える。 最後のデリミタは、イベント行の最後の文字であれば任意である。 デリミタは、バックスラッシュ1つでoldとnewで引用することができる。 もし&がnewに現れた場合、それはoldに置き換えられる。 シングル・バックスラッシュは&を引用符で囲む。 oldがNULLの場合、最後に置換されたoldに設定され、それ以前に履歴の置換が行われなかった場合は、!?string[?]検索の最後の文字列に設定される。 newがNULLの場合、一致するoldはすべて削除される。 |
| ;& | | ;& |
| :Repeat the previous substitution. | | :前の置換を繰り返す。 |
| ;g | | ;g |
| :Cause changes to be applied over the entire event line. This is used in conjunction with `:s' (e.g., `:gs/old/new/') or `:&'. If used with `:s', any delimiter can be used in place of /, and the final delimiter is optional if it is the last character of the event line. An a may be used as a synonym for g. | | :変更をイベント行全体に適用する。 これは `:s' (例えば `:gs/old/new/') または `:&' と組み合わせて使う。 s' と一緒に使う場合、/の代わりにどんな区切り文字でも使うことができ、最後の区切り文字がイベント行の最後の文字であれば省略可能である。 gの同義語としてaを使うこともできる。 |
| ;G | | ;G |
| :Apply the following `s' or `&' modifier once to each word in the event line. | | :以下の`s'または`&'修飾子をイベント行の各単語に1回ずつ適用する。 |
|
| |
|
| == SHELL BUILTIN COMMANDS == | | == SHELL BUILTIN COMMANDS == |
| Unless otherwise noted, each builtin command documented in this section as accepting options preceded by - accepts -- to signify the end of the options. The :, true, false, and test/[ builtins do not accept options and do not treat -- specially. The exit, logout, return, break, continue, let, and shift builtins accept and process arguments beginning with - without requiring --.
| | 特に断りのない限り、このセクションでオプションを受け付けるとして文書化されている各 組み込みコマンドは、オプションの終わりを示す -- を受け付ける。 test/[、true、false、test/[ 組み込み関数はオプションを受け付けず、 -- を特別に扱わない。 exit、logout、return、break、continue、let、shift 組み込み関数は、-- を必要とせずに - で始まる引数を受け入れ処理する。 |
| Other builtins that accept arguments but are not specified as accepting options interpret arguments beginning with - as invalid options and require -- to prevent this interpretation.
| | 引数を受け付けるがオプションを受け付けるように指定されていない他の組み込み関数は、 - で始まる引数を無効なオプションとして解釈し、この解釈を防ぐために -- を要求する。 |
| ;<nowiki>: [arguments]</nowiki> | | ;<nowiki>: [arguments]</nowiki> |
| :No effect; the command does nothing beyond expanding arguments and performing any specified redirections. The return status is zero. | | :コマンドは引数を展開し、指定されたリダイレクションを実行するだけで、何もしない。 リターンステータスは0である。 |
|
| |
|
| ;<nowiki>. filename [arguments]</nowiki> | | ;<nowiki>. filename [arguments]</nowiki> |
| ;<nowiki>source filename [arguments]</nowiki> | | ;<nowiki>source filename [arguments]</nowiki> |
| :Read and execute commands from filename in the current shell environment and return the exit status of the last command executed from filename. If filename does not contain a slash, filenames in PATH are used to find the directory containing filename. The file searched for in PATH need not be executable. When bash is not in posix mode, the current directory is searched if no file is found in PATH. If the sourcepath option to the shopt builtin command is turned off, the PATH is not searched. If any arguments are supplied, they become the positional parameters when filename is executed. Otherwise the positional parameters are unchanged. If the -T option is enabled, source inherits any trap on DEBUG; if it is not, any DEBUG trap string is saved and restored around the call to source, and source unsets the DEBUG trap while it executes. If -T is not set, and the sourced file changes the DEBUG trap, the new value is retained when source completes. The return status is the status of the last command exited within the script (0 if no commands are executed), and false if filename is not found or cannot be read. | | :現在のシェル環境で filename からコマンドを読み込んで実行し、 filename から最後に実行されたコマンドの終了ステータスを返す。 filename にスラッシュが含まれていない場合、PATH 内のファイル名を使用して filename を含むディレクトリを検索する。 PATHで検索されるファイルは実行可能である必要はない。 bashがposixモードでない場合、PATHにファイルが見つからなければ、カレント・ディレクトリが検索される。 shopt組み込みコマンドのsourcepathオプションがオフの場合、PATHは検索されない。 引数が与えられている場合、それらは filename が実行されるときの位置パラメーターとなる。 それ以外の場合、位置パラメーターは変更されない。 -Tオプションが有効な場合、sourceはDEBUGのトラップを継承する。有効でない場合、DEBUGトラップ文字列はsourceへの呼び出しの周囲に保存および復元され、sourceは実行中にDEBUGトラップの設定を解除する。 Tが設定されておらず、ソース・ファイルがDEBUGトラップを変更した場合、ソースが完了すると新しい値が保持される。 戻りステータスは、スクリプト内で最後に終了したコマンドのステータス(コマンドが実行されていない場合は0)であり、filenameが見つからないか読み取れない場合はfalseである。 |
|
| |
|
| ;<nowiki>alias [-p] [name[=value] ...]</nowiki> | | ;<nowiki>alias [-p] [name[=value] ...]</nowiki> |
| :Alias with no arguments or with the -p option prints the list of aliases in the form alias name=value on standard output. When arguments are supplied, an alias is defined for each name whose value is given. A trailing space in value causes the next word to be checked for alias substitution when the alias is expanded. For each name in the argument list for which no value is supplied, the name and value of the alias is printed. Alias returns true unless a name is given for which no alias has been defined. | | :引数なし、または-pオプションを指定したAliasは、alias name=valueという形式でエイリアスのリストを標準出力に表示する。 引数が与えられると、値が与えられる各名称に対してエイリアスが定義される。 valueの末尾に空白があると、エイリアスが展開されるときに、次の単語でエイリアスの置換がチェックされる。 値が与えられていない引数リストの各名に対して、エイリアスの名前と値が表示される。 エイリアスが定義されていない名前が与えられない限り、Aliasは真を返す。 |
|
| |
|
| ;<nowiki>bg [jobspec ...]</nowiki> | | ;<nowiki>bg [jobspec ...]</nowiki> |
| :Resume each suspended job jobspec in the background, as if it had been started with &. If jobspec is not present, the shell's notion of the current job is used. bg jobspec returns 0 unless run when job control is disabled or, when run with job control enabled, any specified jobspec was not found or was started without job control. | | :中断された各 jobspec をバックグラウンドで再開する。 jobspecが存在しない場合、シェルの現在のジョブの概念が使用される。 bg jobspecは、ジョブ制御が無効になっているときに実行されない限り0を返し、ジョブ制御が有効になっているときに実行された場合は、指定されたjobspecが見つからないか、ジョブ制御なしで開始された。 |
|
| |
|
| ;<nowiki>bind [-m keymap] [-lpsvPSVX]</nowiki> | | ;<nowiki>bind [-m keymap] [-lpsvPSVX]</nowiki> |
Line 2,781: |
Line 2,781: |
|
| |
|
| == SHELL COMPATIBILITY MODE == | | == SHELL COMPATIBILITY MODE == |
| Bash-4.0 introduced the concept of a `shell compatibility level', specified as a set of options to the shopt builtin compat31, compat32, compat40, compat41, and so on). There is only one current compatibility level -- each option is mutually exclusive. The compatibility level is intended to allow users to select behavior from previous versions that is incompatible with newer versions while they migrate scripts to use current features and behavior. It's intended to be a temporary solution. | | Bash-4.0では「シェル互換性レベル」という概念が導入され、shopt組み込みのcompat31、compat32、compat40、compat41などに対するオプションのセットとして指定される。) 現在の互換性レベルは1つだけで、各オプションは相互に排他的である。 互換性レベルは、ユーザーが新しいバージョンと互換性のない旧バージョンの動作を選択できるようにするためのもので、スクリプトを移行して現在の機能と動作を使用できるようにするためのものである。これは一時的な解決策である。 |
|
| |
|
| This section does not mention behavior that is standard for a particular version (e.g., setting compat32 means that quoting the rhs of the regexp matching operator quotes special regexp characters in the word, which is default behavior in bash-3.2 and above).
| | このセクションでは、特定のバージョンで標準となっている動作については言及しない(例えば、compat32を設定することは、正規表現マッチング演算子のrhsを引用することで、単語内の特殊な正規表現文字を引用することを意味し、これはbash-3.2以上のデフォルトの動作である)。 |
|
| |
|
| If a user enables, say, compat32, it may affect the behavior of other compatibility levels up to and including the current compatibility level. The idea is that each compatibility level controls behavior that changed in that version of bash, but that behavior may have been present in earlier versions. For instance, the change to use locale-based comparisons with the [[ command came in bash-4.1, and earlier versions used ASCII-based comparisons, so enabling compat32 will enable ASCII-based comparisons as well. That granularity may not be sufficient for all uses, and as a result users should employ compatibility levels carefully. Read the documentation for a particular feature to find out the current behavior.
| | ユーザーが例えばcompat32を有効にすると、現在の互換性レベルまでの他の互換性レベルの動作に影響を与える可能性がある。 各互換性レベルは、そのバージョンのbashで変更された動作を制御するが、その動作は以前のバージョンにもあったかもしれないという考え方である。 例えば、[[ コマンドでロケール・ベースの比較を使用するようになったのはbash-4.1からで、それ以前のバージョンではASCIIベースの比較を使っていたため、compat32を有効にするとASCIIベースの比較も有効になる。 そのため、compat32を有効にすると、ASCIIベースの比較も有効になる。この細かさは、すべての用途に十分とは限らないので、ユーザーは互換性レベルを慎重に使用すべきである。 現在の動作を知るには、特定の機能のドキュメントを読むこと。 |
|
| |
|
| Bash-4.3 introduced a new shell variable: BASH_COMPAT. The value assigned to this variable (a decimal version number like 4.2, or an integer corresponding to the compatNN option, like 42) determines the compatibility level. | | Bash-4.3は新しいシェル変数を導入した: BASH_COMPATである。 この変数に代入される値(4.2のような10進数のバージョン番号、または42のようなcompatNNオプションに対応する整数)が互換性レベルを決定する。 |
|
| |
|
| Starting with bash-4.4, Bash has begun deprecating older compatibility levels. Eventually, the options will be removed in favor of BASH_COMPAT.
| | bash-4.4から、Bashは古い互換性レベルを廃止し始めた。 最終的にはこのオプションは削除され、BASH_COMPATが使われるようになる。 |
|
| |
|
| Bash-5.0 is the final version for which there will be an individual shopt option for the previous version. Users should use BASH_COMPAT on bash-5.0 and later versions. | | Bash-5.0は、以前のバージョンに対する個別のshoptオプションが存在する最後のバージョンである。ユーザーはbash-5.0以降のバージョンでBASH_COMPATを使うべきである。 |
|
| |
|
| The following table describes the behavior changes controlled by each compatibility level setting. The compatNN tag is used as shorthand for setting the compatibility level to NN using one of the following mechanisms. For versions prior to bash-5.0, the compatibility level may be set using the corresponding compatNN shopt option. For bash-4.3 and later versions, the BASH_COMPAT variable is preferred, and it is required for bash-5.1 and later versions.
| | 以下の表は、各互換性レベルの設定によって制御される動作の変更について説明したものである。 compatNNタグは、以下のメカニズムのいずれかを使用して互換性レベルをNNに設定するための省略記法として使用される。 bash-5.0より前のバージョンでは、対応するcompatNN shoptオプションを使用して互換性レベルを設定することができる。 bash-4.3およびそれ以降のバージョンでは、BASH_COMPAT変数を使用するのが望ましく、bash-5.1およびそれ以降のバージョンでは必須である。 |
|
| |
|
| ;compat31 | | ;compat31 |
| * quoting the rhs of the [[ command's regexp matching operator (=~) has no special effect | | * コマンドの正規表現マッチング演算子(=~)のrhsを引用しても特別な効果はない。 |
|
| |
|
| ;compat32 | | ;compat32 |
| * interrupting a command list such as "a ; b ; c" causes the execution of the next command in the list (in bash-4.0 and later versions, the shell acts as if it received the interrupt, so interrupting one command in a list aborts the execution of the entire list) | | * "a ; b ; c "のようなコマンドリストに割り込むと、リスト内の次のコマンドが実行される(bash-4.0以降のバージョンでは、シェルは割り込みを受け取ったかのように動作するため、リスト内の1つのコマンドに割り込むと、リスト全体の実行が中断される)。 |
|
| |
|
| ;compat40 | | ;compat40 |
| * the < and > operators to the [[ command do not consider the current locale when comparing strings; they use ASCII ordering. Bash versions prior to bash-4.1 use ASCII collation and strcmp(3); bash-4.1 and later use the current locale's collation sequence and strcoll(3). | | * コマンドの < と > 演算子は、文字列を比較するときに現在のロケールを考慮しない。 bash-4.1以前のバージョンでは、ASCII照合順序と[https://manpages.debian.org/unstable/manpages-dev/strcmp.3.en.html strcmp](3)を使用する。bash-4.1以降では、現在のロケールの照合順序と[https://manpages.debian.org/unstable/manpages-dev/strcoll.3.en.html strcoll](3)を使用する。 |
|
| |
|
| ;compat41 | | ;compat41 |
| * in posix mode, time may be followed by options and still be recognized as a reserved word (this is POSIX interpretation 267) | | * posixモードでは、timeの後にオプションを付けても予約語として認識される(これはPOSIX解釈267)。 |
| * in posix mode, the parser requires that an even number of single quotes occur in the word portion of a double-quoted parameter expansion and treats them specially, so that characters within the single quotes are considered quoted (this is POSIX interpretation 221) | | * posix モードでは、パーサーは二重引用符で囲まれたパラメータ展開の単語部分に偶数の一重引用符があることを要求し、一重引用符内の文字が引用符で囲まれたとみなされるように、それらを特別に扱う(これは POSIX 解釈 221 である)。 |
|
| |
|
| ;compat42 | | ;compat42 |
| * the replacement string in double-quoted pattern substitution does not undergo quote removal, as it does in versions after bash-4.2 | | * 二重引用符で囲まれたパターン置換の置換文字列は、bash-4.2以降のバージョンでは引用符の削除を行わない。 |
| * in posix mode, single quotes are considered special when expanding the word portion of a double-quoted parameter expansion and can be used to quote a closing brace or other special character (this is part of POSIX interpretation 221); in later versions, single quotes are not special within double-quoted word expansions | | * posixモードでは、二重引用符で囲まれたパラメータ展開の単語部分を展開するとき、一重引用符は特別なものとみなされ、閉じ波括弧や他の特別な文字を引用するために使用できる(これはPOSIX解釈221の一部である)。 |
|
| |
|
| ;compat43 | | ;compat43 |
| * the shell does not print a warning message if an attempt is made to use a quoted compound assignment as an argument to declare (declare -a foo='(1 2)'). Later versions warn that this usage is deprecated | | * シェルは、引用符で囲まれた複合代入をdeclareの引数として使おうとしても警告メッセージを表示しない(declare -a foo='(1 2)')。後のバージョンでは、この使い方が非推奨であることを警告する |
| * word expansion errors are considered non-fatal errors that cause the current command to fail, even in posix mode (the default behavior is to make them fatal errors that cause the shell to exit) | | * 単語展開エラーは、posixモードであっても、現在のコマンドを失敗させる非致命的エラーとみなされる(デフォルトの動作は、シェルを終了させる致命的エラーとなる)。 |
| * when executing a shell function, the loop state (while/until/etc.) is not reset, so break or continue in that function will break or continue loops in the calling context. Bash-4.4 and later reset the loop state to prevent this | | * シェル関数を実行するとき、ループ状態(while/until/etc)はリセットされないため、その関数内でbreakやcontinueを行うと、呼び出し元のコンテキストでループが解除されたり継続されたりする。Bash-4.4以降では、ループ状態をリセットしてこれを防いでいる。 |
|
| |
|
| ;compat44 | | ;compat44 |
| * the shell sets up the values used by BASH_ARGV and BASH_ARGC so they can expand to the shell's positional parameters even if extended debugging mode is not enabled | | * シェルがBASH_ARGVとBASH_ARGCで使用する値を設定し、拡張デバッグモードが有効になっていなくても、シェルの位置パラメーターに展開できるようにする。 |
| * a subshell inherits loops from its parent context, so break or continue will cause the subshell to exit. Bash-5.0 and later reset the loop state to prevent the exit | | * サブシェルは親コンテキストからループを継承するため、breakやcontinueはサブシェルを終了させる。 Bash-5.0以降では、ループ状態をリセットして終了を防止する。 |
| *variable assignments preceding builtins like export and readonly that set attributes continue to affect variables with the same name in the calling environment even if the shell is not in posix mode | | *シェルがposixモードでなくても、exportやreadonlyのような属性を設定する組み込み関数に先行する変数代入は、呼び出し環境の同じ名前の変数に影響を与え続ける。 |
|
| |
|
| ;compat50 | | ;compat50 |
| * Bash-5.1 changed the way $RANDOM is generated to introduce slightly more randomness. If the shell compatibility level is set to 50 or lower, it reverts to the method from bash-5.0 and previous versions, so seeding the random number generator by assigning a value to RANDOM will produce the same sequence as in bash-5.0 | | * Bash-5.1では、$RANDOMの生成方法が変更され、若干ランダム性が増した。 シェルの互換性レベルが50以下に設定されている場合、bash-5.0とそれ以前のバージョンの方法に戻るので、RANDOMに値を代入して乱数ジェネレーターをシードすると、bash-5.0と同じシーケンスが生成される。 |
| * If the command hash table is empty, bash versions prior to bash-5.1 printed an informational message to that effect, even when producing output that can be reused as input. Bash-5.1 suppresses that message when the -l option is supplied. | | * コマンド・ハッシュ・テーブルが空の場合、bash-5.1より前のバージョンのbashでは、入力として再利用できる出力を生成する場合でも、その旨の情報メッセージが表示された。Bash-5.1では、-lオプションが指定されると、このメッセージが表示されなくなる。 |
|
| |
|
| == RESTRICTED SHELL == | | == RESTRICTED SHELL == |