X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=doc%2Fbash.html;h=bba7db6c084e447c7ffb65757414e6c4a2be78f3;hb=ac50fbac377e32b98d2de396f016ea81e8ee9961;hp=d1b64895c3c7b1b6a1fe114ad22f7ccdafcafb3b;hpb=4539d736f1aff232857a854fd2a68df0c98d9f34;p=platform%2Fupstream%2Fbash.git diff --git a/doc/bash.html b/doc/bash.html index d1b6489..bba7db6 100644 --- a/doc/bash.html +++ b/doc/bash.html @@ -3,7 +3,7 @@
BASH(1) | 2010 December 28 | BASH(1) + | BASH(1) | 2014 February 2 | BASH(1) |
---|
If @@ -544,8 +550,8 @@ The option may be used to inhibit this behavior, and the --rcfile -option may be used to force another file to be read, but -rshd does not generally invoke the shell with those options +option may be used to force another file to be read, but neither +rshd nor sshd generally invoke the shell with those options or allow them to be specified.
@@ -654,7 +660,7 @@ command: -! case do done elif else esac fi for function if in select then until while { } time [[ ]] +! case coproc do done elif else esac fi for function if in select then until while { } time [[ ]]
The return status of a pipeline is the exit status of the last @@ -869,7 +876,10 @@ executed in the list.
-A compound command is one of the following: +A compound command is one of the following. +In most cases a list in a command's description may be separated from +the rest of the command by one or more newlines, and may be followed by a +newline in place of a semicolon.
@@ -948,8 +961,12 @@ If the shell option
is enabled, the match is performed without regard to the case
of alphabetic characters.
-Any part of the pattern may be quoted to force it to be matched as a
-string.
+Any part of the pattern may be quoted to force the quoted portion
+to be matched as a string.
+Bracket expressions in regular expressions must be treated carefully,
+since normal quoting characters lose their meanings between brackets.
+If the pattern is stored in a shell variable, quoting the variable
+expansion forces the entire pattern to be matched as a string.
Substrings matched by parenthesized subexpressions within the regular
expression are saved in the array variable
BASH_REMATCH.
@@ -1113,7 +1130,7 @@ on a successful match.
The exit status is zero if no
pattern matches. Otherwise, it is the exit status of the
last command executed in list.
-
This creates a coprocess named NAME.
-If NAME is not supplied, the default name is COPROC.
+If NAME is not supplied, the default name is COPROC.
NAME must not be supplied if command is a simple
command (see above); otherwise, it is interpreted as the first word
of the simple command.
-When the coproc is executed, the shell creates an array variable (see
+When the coprocess is executed, the shell creates an array variable (see
Arrays
below) named NAME in the context of the executing shell.
@@ -1193,12 +1210,15 @@ command (see
below).
The file descriptors can be utilized as arguments to shell commands
and redirections using standard word expansions.
+The file descriptors are not available in subshells.
The process ID of the shell spawned to execute the coprocess is
available as the value of the variable NAME_PID.
The wait
builtin command may be used to wait for the coprocess to terminate.
+Since the coprocess is created as an asynchronous command,
+the coproc command always returns success.
The return status of a coprocess is the exit status of command.
In the context where an assignment statement is assigning a value
@@ -1578,6 +1603,41 @@ appended to the array beginning at one greater than the array's maximum index
associative array.
When applied to a string-valued variable, value is expanded and
appended to the variable's value.
+
+
+A variable can be assigned the nameref attribute using the
+-n option to the declare or local builtin commands
+(see the descriptions of declare and local below)
+to create a nameref, or a reference to another variable.
+This allows variables to be manipulated indirectly.
+Whenever the nameref variable is referenced or assigned to, the operation
+is actually performed on the variable specified by the nameref variable's
+value.
+A nameref is commonly used within shell functions to refer to a variable
+whose name is passed as an argument to the function.
+For instance, if a variable name is passed to a shell function as its first
+argument, running
+
+
+inside the function creates a nameref variable ref whose value is
+the variable name passed as the first argument.
+References and assignments to ref are treated as references and
+assignments to the variable whose name was passed as $1.
+If the control variable in a for loop has the nameref attribute,
+the list of words can be a list of shell variables, and a name reference
+will be established for each word in the list, in turn, when the loop is
+executed.
+Array variables cannot be given the -n attribute.
+However, nameref variables can reference array variables and subscripted
+array variables.
+Namerefs can be unset using the -n option to the unset builtin.
+Otherwise, if unset is executed with the name of a nameref variable
+as an argument, the variable referenced by the nameref variable will be unset.
Shell Function Definitions
@@ -1224,6 +1244,8 @@ That command is usually a list of commands between { and }, but
may be any command listed under Compound Commands above.
compound-command is executed whenever name is specified as the
name of a simple command.
+When in posix mode, name may not be the name of one of the
+POSIX special builtins.
Any redirections (see
REDIRECTION
@@ -1560,6 +1582,9 @@ and
local
builtin commands.
+When in posix mode, these builtins may appear in a command after
+one or more instances of the command builtin and retain these
+assignment statement properties.
+
+Positional Parameters
@@ -1619,8 +1679,12 @@ only be referenced; assignment to them is not allowed.
+
is subjected to parameter expansion, command substitution, and arithmetic
-expansion before being interpreted as a file name.
+expansion before being interpreted as a filename.
PATH
-is not used to search for the resultant file name.
+is not used to search for the resultant filename.
An indexed array is created automatically if any variable is assigned to @@ -3023,12 +3138,6 @@ using the syntax name[subscript]=value. The subscript is treated as an arithmetic expression that must evaluate to a number. -If -subscript - -evaluates to a number less than zero, it is used as -an offset from one greater than the array's maximum index (so a subcript -of -1 refers to the last element of the array). To explicitly declare an indexed array, use declare -a name @@ -3060,7 +3169,7 @@ builtins. Each attribute applies to all members of an array. Arrays are assigned to using compound assignments of the form name=(value1 ... valuen), where each value is of the form [subscript]=string. -Indexed array assignments do not require the bracket and subscript. +Indexed array assignments do not require anything but string. When assigning to indexed arrays, if the optional brackets and subscript are supplied, that index is assigned to; otherwise the index of the element assigned is the last index assigned @@ -3075,6 +3184,13 @@ This syntax is also accepted by the builtin. Individual array elements may be assigned to using the name[subscript]=value syntax introduced above. +When assigning to an indexed array, if +name + +is subscripted by a negative number, that number is +interpreted as relative to one greater than the maximum index of +name, so negative indices count back from the end of the +array, and an index of -1 references the last element.
Any element of an array may be referenced using @@ -3105,17 +3221,33 @@ ${name[subscript]}. If subscript is * or @, the expansion is the number of elements in the array. Referencing an array variable without a subscript is equivalent to referencing the array with a subscript of 0. +If the +subscript + +used to reference an element of an indexed array +evaluates to a number less than zero, it is +interpreted as relative to one greater than the maximum index of the array, +so negative indices count back from the end of the +array, and an index of -1 references the last element.
An array variable is considered set if a subscript has been assigned a value. The null string is a valid value.
+It is possible to obtain the keys (indices) of an array as well as the values. +${!name[@]} and ${!name[*]} +expand to the indices assigned in array variable name. +The treatment when in double quotes is similar to the expansion of the +special parameters @ and * within double quotes. +
+ The unset builtin is used to destroy arrays. unset name[subscript] destroys the array element at index subscript. +Negative subscripts to indexed arrays are interpreted as described above. Care must be taken to avoid unwanted side effects caused by pathname expansion. unset name, where name is an array, or @@ -3138,6 +3270,10 @@ option to specify an indexed array and a -A option to specify an associative array. +If both options are supplied, +-A + +takes precedence. The read @@ -3175,15 +3311,19 @@ and
-The order of expansions is: brace expansion, tilde expansion, -parameter, variable and arithmetic expansion and -command substitution -(done in a left-to-right fashion), word splitting, and pathname -expansion. +The order of expansions is: +brace expansion; +tilde expansion, parameter and variable expansion, arithmetic expansion, +and command substitution (done in a left-to-right fashion); +word splitting; +and pathname expansion.
On systems that can support it, there is an additional expansion available: process substitution. +This is performed at the +same time as tilde, parameter, variable, and arithmetic expansion and +command substitution.
Only brace expansion, word splitting, and pathname expansion @@ -3231,12 +3371,14 @@ and incr, an optional increment, is an integer. When integers are supplied, the expression expands to each number between x and y, inclusive. Supplied integers may be prefixed with 0 to force each term to have the -same width. When either x or y begins with a zero, the shell +same width. +When either x or y begins with a zero, the shell attempts to force all generated terms to contain the same number of digits, zero-padding where necessary. When characters are supplied, the expression expands to each character -lexicographically between x and y, inclusive. Note that -both x and y must be of the same type. +lexicographically between x and y, inclusive, +using the default C locale. +Note that both x and y must be of the same type. When the increment is supplied, it is used as the difference between each term. The default increment is 1 or -1 as appropriate.
@@ -3377,7 +3519,7 @@ or the first =. In these cases, tilde expansion is also performed. -Consequently, one may use file names with tildes in assignments to +Consequently, one may use filenames with tildes in assignments to PATH, @@ -3421,18 +3563,20 @@ or when is followed by a character which is not to be interpreted as part of its name. +The parameter is a shell parameter as described above +PARAMETERS) or an array reference (Arrays).
If the first character of parameter is an exclamation point (!), -a level of variable indirection is introduced. +it introduces a level of variable indirection. Bash uses the value of the variable formed from the rest of parameter as the name of the variable; this variable is then expanded and that value is used in the rest of the substitution, rather than the value of parameter itself. This is known as indirect expansion. -The exceptions to this are the expansions of ${!\fPfIprefix*} and +The exceptions to this are the expansions of ${!prefix*} and ${!name[@]} described below. The exclamation point must immediately follow the left brace in order to introduce indirection. @@ -3442,7 +3586,8 @@ In each of the cases below, word is subject to tilde expansion, parameter expansion, command substitution, and arithmetic expansion.
-When not performing substring expansion, using the forms documented below, +When not performing substring expansion, using the forms documented below +(e.g., :-), bash tests for a parameter that is unset or null. Omitting the colon results in a test only for a parameter that is unset.
@@ -3502,33 +3647,50 @@ is substituted.
If offset evaluates to a number less than zero, the value -is used as an offset from the end of the value of parameter. -If length evaluates to a number less than zero, and parameter -is not @ and not an indexed or associative array, it is interpreted -as an offset from the end of the value of parameter rather than -a number of characters, and the expansion is the characters between the -two offsets. +is used as an offset in characters +from the end of the value of parameter. +If length evaluates to a number less than zero, +it is interpreted as an offset in characters +from the end of the value of parameter rather than +a number of characters, and the expansion is the characters between +offset and that result. +Note that a negative offset must be separated from the colon by at least +one space to avoid being confused with the :- expansion. +
If parameter is @, the result is length positional parameters beginning at offset. +A negative offset is taken relative to one greater than the greatest +positional parameter, so an offset of -1 evaluates to the last positional +parameter. +It is an expansion error if length evaluates to a number less than +zero. +
If parameter is an indexed array name subscripted by @ or *, the result is the length members of the array beginning with ${parameter[offset]}. A negative offset is taken relative to one greater than the maximum index of the specified array. +It is an expansion error if length evaluates to a number less than +zero. +
Substring expansion applied to an associative array produces undefined results. -Note that a negative offset must be separated from the colon by at least -one space to avoid being confused with the :- expansion. +
Substring indexing is zero-based unless the positional parameters are used, in which case the indexing starts at 1 by default. If offset is 0, and the positional parameters are used, $0 is @@ -3580,6 +3742,13 @@ or @, the value substituted is the number of elements in the array. +If +parameter + +is an indexed array name subscripted by a negative number, that number is +interpreted as relative to one greater than the maximum index of +parameter, so negative indices count back from the end of the +array, and an index of -1 references the last element.
-
@@ -3808,8 +3978,9 @@ The is treated as if it were within double quotes, but a double quote inside the parentheses is not treated specially. -All tokens in the expression undergo parameter expansion, string -expansion, command substitution, and quote removal. +All tokens in the expression undergo parameter and variable expansion, +command substitution, and quote removal. +The result is treated as the arithmetic expression to be evaluated. Arithmetic expansions may be nested.
@@ -3868,7 +4039,8 @@ The shell treats each character of as a delimiter, and splits the results of the other -expansions into words on these characters. If +expansions into words using these characters as field terminators. +If IFS @@ -3973,8 +4145,13 @@ regarded as a pattern, and replaced with an alphabetically sorted list of -file names matching the pattern. -If no matching file names are found, +filenames matching the pattern +(see +Pattern Matching + + +below). +If no matching filenames are found, and the shell option nullglob @@ -4033,19 +4210,19 @@ The GLOBIGNORE -shell variable may be used to restrict the set of file names matching a +shell variable may be used to restrict the set of filenames matching a pattern. If GLOBIGNORE -is set, each matching file name that also matches one of the patterns in +is set, each matching filename that also matches one of the patterns in GLOBIGNORE is removed from the list of matches. -The file names +The filenames ``.'' and @@ -4062,11 +4239,11 @@ is set and not null. However, setting to a non-null value has the effect of enabling the dotglob -shell option, so all other file names beginning with a +shell option, so all other filenames beginning with a ``.'' will match. -To get the old behavior of ignoring file names beginning with a +To get the old behavior of ignoring filenames beginning with a ``.'', make @@ -4123,7 +4300,7 @@ Matches any single character. Matches any one of the enclosed characters. A pair of characters separated by a hyphen denotes a range expression; -any character that sorts between those two characters, inclusive, +any character that falls between those two characters, inclusive, using the current locale's collating sequence and character set, is matched. If the first character following the [ @@ -4136,12 +4313,31 @@ or a then any character not enclosed is matched. The sorting order of characters in range expressions is determined by -the current locale and the value of the +the current locale and the values of the LC_COLLATE -shell variable, -if set. +or +LC_ALL + + +shell variables, if set. +To obtain the traditional interpretation of range expressions, where +[a-d] + +is equivalent to +[abcd], + +set value of the +LC_ALL + +shell variable to +C, + +or enable the +globasciiranges + +shell option. A - @@ -4257,8 +4453,13 @@ may be redirected using a special notation interpreted by the shell. -Redirection may also be used to open and close files for the -current shell execution environment. The following redirection +Redirection allows commands' file handles to be +duplicated, opened, closed, +made to refer to different files, +and can change the files the command reads from and writes to. +Redirection may also be used to modify file handles in the +current shell execution environment. +The following redirection operators may precede or appear anywhere within a simple command @@ -4273,7 +4474,8 @@ Each redirection that may be preceded by a file descriptor number may instead be preceded by a word of the form {varname}. In this case, for each redirection operator except >&- and <&-, the shell will allocate a file descriptor greater -than 10 and assign it to varname. If >&- or <&- is preceded +than or equal to 10 and assign it to varname. +If >&- or <&- is preceded by {varname}, the value of varname defines the file descriptor to close.
@@ -4291,9 +4493,10 @@ the redirection refers to the standard output (file descriptor
The word following the redirection operator in the following -descriptions, unless otherwise noted, is subjected to brace expansion, -tilde expansion, parameter expansion, command substitution, arithmetic -expansion, quote removal, pathname expansion, and word splitting. +descriptions, unless otherwise noted, is subjected to +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, quote removal, +pathname expansion, and word splitting. If it expands to more than one word, bash @@ -4359,13 +4562,13 @@ File descriptor 2 is duplicated.
+When using the second form, word may not expand to a number or +-. If it does, other redirection operators apply +(see Duplicating File Descriptors below) for compatibility +reasons.
+ +(see Duplicating File Descriptors below).
-No parameter expansion, command substitution, arithmetic expansion, -or pathname expansion is performed on +No parameter and variable expansion, command substitution, +arithmetic expansion, or pathname expansion is performed on word. If any characters in @@ -4597,9 +4807,9 @@ is the result of quote removal on and the lines in the here-document are not expanded. If word is unquoted, -all lines of the here-document are subjected to parameter expansion, -command substitution, and arithmetic expansion. In the latter -case, the character sequence +all lines of the here-document are subjected to +parameter expansion, command substitution, and arithmetic expansion, +the character sequence \<newline> is ignored, and @@ -4640,8 +4850,12 @@ A variant of here documents, the format is:
-The word is expanded and supplied to the command on its standard -input. +The word undergoes +brace expansion, tilde expansion, parameter and variable expansion, +command substitution, arithmetic expansion, and quote removal. +Pathname expansion and word splitting are not performed. +The result is supplied as a single string to the command on its +standard input.
Next, any command specified with the -C option is invoked
@@ -7922,7 +8202,7 @@ completion function would load completions dynamically:
}
-complete -D -F _completion_loader
+complete -D -F _completion_loader -o bashdefault -o default
@@ -7980,6 +8260,8 @@ the number of lines specified by the value of
HISTFILESIZE.
+If HISTFILESIZE is unset, or set to null, a non-numeric value,
+or a numeric value less than zero, the history file is not truncated.
When the history file is read,
lines beginning with the history comment character followed immediately
by a digit are interpreted as timestamps for the preceding history line.
@@ -7988,7 +8270,7 @@ These timestamps are optionally displayed depending on the value of the
variable.
-When an interactive shell exits, the last
+When a shell with history enabled exits, the last
$HISTSIZE
@@ -8033,7 +8315,8 @@ lines. If
HISTFILESIZE
-is not set, no truncation is performed.
+is unset, or set to null, a non-numeric value,
+or a numeric value less than zero, the history file is not truncated.
The builtin command @@ -8248,7 +8531,7 @@ history list starting with
@@ -8739,22 +9028,26 @@ current frame is frame 0. The return value is 0 unless the shell is not executing a subroutine call or expr does not correspond to a valid position in the call stack. -
@@ -9354,15 +9686,15 @@ of the directory stack.
In the second form, command is re-executed after each instance of pat is replaced by rep. +Command is intepreted the same as first above. A useful alias to use with this is r='fc -s', @@ -9858,7 +10183,7 @@ can report errors in two ways. If the first character of is a colon, silent -error reporting is used. In normal operation diagnostic messages +error reporting is used. In normal operation, diagnostic messages are printed when invalid options or missing option arguments are encountered. If the variable @@ -9936,7 +10261,7 @@ If the option is supplied, no path search is performed, and filename -is used as the full file name of the command. +is used as the full filename of the command. The -r @@ -9990,11 +10315,14 @@ Display the description of each pattern in a manpage-like format
The return status is 0 unless no command matches pattern. + +
@@ -10460,10 +10788,13 @@ causes printf to output the corresponding
@@ -10518,7 +10849,8 @@ Adds dir to the directory stack at the top, making it the -new current working directory. +new current working directory as if it had been supplied as the argument +to the cd builtin.
@@ -10583,7 +10915,8 @@ The characters in IFS -are used to split the line into words. +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: @@ -10666,14 +10999,18 @@ not echoed.
+ + +If a compound command or shell function executes in a context +where -e is being ignored, +none of the commands executed within the compound command or function body +will be affected by the -e setting, even if -e is set +and a command returns a failure status. +If a compound command or shell function sets -e while executing in +a context where -e is ignored, that setting will not have any +effect until the compound command or the command containing the function +call completes.
@@ -11353,7 +11739,7 @@ If set, minor errors in the spelling of a directory component in a command will be corrected. The errors checked for are transposed characters, a missing character, and one character too many. -If a correction is found, the corrected file name is printed, +If a correction is found, the corrected filename is printed, and the command proceeds. This option is only used by interactive shells.
@@ -12115,7 +12572,7 @@ If a command is hashed,
and
-P
-print the hashed value, not necessarily the file that appears
+print the hashed value, which is not necessarily the file that appears
first in
PATH.
@@ -12265,20 +12722,21 @@ The maximum number of threads
If
limit
-is given, it is the new value of the specified resource (the
+is given, and the
-a
-option is display only).
+option is not used,
+limit is the new value of the specified resource.
If no option is given, then
-f
is assumed. Values are in 1024-byte increments, except for
-t,
-which is in seconds,
+which is in seconds;
-p,
-which is in units of 512-byte blocks,
+which is in units of 512-byte blocks;
and
-T,
@@ -12334,18 +12792,18 @@ value is true unless a supplied
name
is not a defined alias.
-BUGS
@@ -12691,7 +13164,7 @@ There may be only one active coprocess at a time.
-
GNU Bash-4.2 2010 December 28 BASH(1)
+ GNU Bash 4.3 2014 February 2 BASH(1)
@@ -12797,6 +13270,6 @@ There may be only one active coprocess at a time.
This document was created by man2html from bash.1.
-Time: 28 December 2010 14:30:29 EST
+Time: 24 February 2014 08:28:34 EST