mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-07 18:52:35 +02:00
commit bash-20170324 snapshot
This commit is contained in:
+115
-79
@@ -9,7 +9,7 @@ SSYYNNOOPPSSIISS
|
||||
bbaasshh [options] [command_string | file]
|
||||
|
||||
CCOOPPYYRRIIGGHHTT
|
||||
Bash is Copyright (C) 1989-2016 by the Free Software Foundation, Inc.
|
||||
Bash is Copyright (C) 1989-2017 by the Free Software Foundation, Inc.
|
||||
|
||||
DDEESSCCRRIIPPTTIIOONN
|
||||
BBaasshh is an sshh-compatible command language interpreter that executes
|
||||
@@ -22,9 +22,9 @@ DDEESSCCRRIIPPTTIIOONN
|
||||
|
||||
OOPPTTIIOONNSS
|
||||
All of the single-character shell options documented in the description
|
||||
of the sseett builtin command can be used as options when the shell is
|
||||
invoked. In addition, bbaasshh interprets the following options when it is
|
||||
invoked:
|
||||
of the sseett builtin command, including --oo, can be used as options when
|
||||
the shell is invoked. In addition, bbaasshh interprets the following
|
||||
options when it is invoked:
|
||||
|
||||
--cc If the --cc option is present, then commands are read from the
|
||||
first non-option argument _c_o_m_m_a_n_d___s_t_r_i_n_g. If there are argu-
|
||||
@@ -1286,9 +1286,9 @@ PPAARRAAMMEETTEERRSS
|
||||
command (see SSHHEELLLL GGRRAAMMMMAARR above).
|
||||
PPSS44 The value of this parameter is expanded as with PPSS11 and the
|
||||
value is printed before each command bbaasshh displays during an
|
||||
execution trace. The first character of PPSS44 is replicated mul-
|
||||
tiple times, as necessary, to indicate multiple levels of indi-
|
||||
rection. The default is ``++ ''.
|
||||
execution trace. The first character of the expanded value of
|
||||
PPSS44 is replicated multiple times, as necessary, to indicate mul-
|
||||
tiple levels of indirection. The default is ``++ ''.
|
||||
SSHHEELLLL The full pathname to the shell is kept in this environment vari-
|
||||
able. If it is not set when the shell starts, bbaasshh assigns to
|
||||
it the full pathname of the current user's login shell.
|
||||
@@ -2176,12 +2176,11 @@ RREEDDIIRREECCTTIIOONN
|
||||
|
||||
[_n]<<<<<<_w_o_r_d
|
||||
|
||||
The _w_o_r_d undergoes brace expansion, tilde expansion, parameter and
|
||||
variable expansion, command substitution, arithmetic expansion, and
|
||||
quote removal. Pathname expansion and word splitting are not per-
|
||||
formed. The result is supplied as a single string, with a newline
|
||||
appended, to the command on its standard input (or file descriptor _n if
|
||||
_n is specified).
|
||||
The _w_o_r_d undergoes tilde expansion, parameter and variable expansion,
|
||||
command substitution, arithmetic expansion, and quote removal. Path-
|
||||
name expansion and word splitting are not performed. The result is
|
||||
supplied as a single string, with a newline appended, to the command on
|
||||
its standard input (or file descriptor _n if _n is specified).
|
||||
|
||||
DDuupplliiccaattiinngg FFiillee DDeessccrriippttoorrss
|
||||
The redirection operator
|
||||
@@ -2189,22 +2188,22 @@ RREEDDIIRREECCTTIIOONN
|
||||
[_n]<<&&_w_o_r_d
|
||||
|
||||
is used to duplicate input file descriptors. If _w_o_r_d expands to one or
|
||||
more digits, the file descriptor denoted by _n is made to be a copy of
|
||||
that file descriptor. If the digits in _w_o_r_d do not specify a file
|
||||
descriptor open for input, a redirection error occurs. If _w_o_r_d evalu-
|
||||
ates to --, file descriptor _n is closed. If _n is not specified, the
|
||||
more digits, the file descriptor denoted by _n is made to be a copy of
|
||||
that file descriptor. If the digits in _w_o_r_d do not specify a file
|
||||
descriptor open for input, a redirection error occurs. If _w_o_r_d evalu-
|
||||
ates to --, file descriptor _n is closed. If _n is not specified, the
|
||||
standard input (file descriptor 0) is used.
|
||||
|
||||
The operator
|
||||
|
||||
[_n]>>&&_w_o_r_d
|
||||
|
||||
is used similarly to duplicate output file descriptors. If _n is not
|
||||
specified, the standard output (file descriptor 1) is used. If the
|
||||
digits in _w_o_r_d do not specify a file descriptor open for output, a re-
|
||||
direction error occurs. If _w_o_r_d evaluates to --, file descriptor _n is
|
||||
closed. As a special case, if _n is omitted, and _w_o_r_d does not expand
|
||||
to one or more digits or --, the standard output and standard error are
|
||||
is used similarly to duplicate output file descriptors. If _n is not
|
||||
specified, the standard output (file descriptor 1) is used. If the
|
||||
digits in _w_o_r_d do not specify a file descriptor open for output, a re-
|
||||
direction error occurs. If _w_o_r_d evaluates to --, file descriptor _n is
|
||||
closed. As a special case, if _n is omitted, and _w_o_r_d does not expand
|
||||
to one or more digits or --, the standard output and standard error are
|
||||
redirected as described previously.
|
||||
|
||||
MMoovviinngg FFiillee DDeessccrriippttoorrss
|
||||
@@ -2212,7 +2211,7 @@ RREEDDIIRREECCTTIIOONN
|
||||
|
||||
[_n]<<&&_d_i_g_i_t--
|
||||
|
||||
moves the file descriptor _d_i_g_i_t to file descriptor _n, or the standard
|
||||
moves the file descriptor _d_i_g_i_t to file descriptor _n, or the standard
|
||||
input (file descriptor 0) if _n is not specified. _d_i_g_i_t is closed after
|
||||
being duplicated to _n.
|
||||
|
||||
@@ -2220,7 +2219,7 @@ RREEDDIIRREECCTTIIOONN
|
||||
|
||||
[_n]>>&&_d_i_g_i_t--
|
||||
|
||||
moves the file descriptor _d_i_g_i_t to file descriptor _n, or the standard
|
||||
moves the file descriptor _d_i_g_i_t to file descriptor _n, or the standard
|
||||
output (file descriptor 1) if _n is not specified.
|
||||
|
||||
OOppeenniinngg FFiillee DDeessccrriippttoorrss ffoorr RReeaaddiinngg aanndd WWrriittiinngg
|
||||
@@ -2228,81 +2227,102 @@ RREEDDIIRREECCTTIIOONN
|
||||
|
||||
[_n]<<>>_w_o_r_d
|
||||
|
||||
causes the file whose name is the expansion of _w_o_r_d to be opened for
|
||||
both reading and writing on file descriptor _n, or on file descriptor 0
|
||||
causes the file whose name is the expansion of _w_o_r_d to be opened for
|
||||
both reading and writing on file descriptor _n, or on file descriptor 0
|
||||
if _n is not specified. If the file does not exist, it is created.
|
||||
|
||||
AALLIIAASSEESS
|
||||
_A_l_i_a_s_e_s allow a string to be substituted for a word when it is used as
|
||||
the first word of a simple command. The shell maintains a list of
|
||||
aliases that may be set and unset with the aalliiaass and uunnaalliiaass builtin
|
||||
commands (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The first word of each
|
||||
simple command, if unquoted, is checked to see if it has an alias. If
|
||||
so, that word is replaced by the text of the alias. The characters //,
|
||||
$$, ``, and == and any of the shell _m_e_t_a_c_h_a_r_a_c_t_e_r_s or quoting characters
|
||||
_A_l_i_a_s_e_s allow a string to be substituted for a word when it is used as
|
||||
the first word of a simple command. The shell maintains a list of
|
||||
aliases that may be set and unset with the aalliiaass and uunnaalliiaass builtin
|
||||
commands (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below). The first word of each
|
||||
simple command, if unquoted, is checked to see if it has an alias. If
|
||||
so, that word is replaced by the text of the alias. The characters //,
|
||||
$$, ``, and == and any of the shell _m_e_t_a_c_h_a_r_a_c_t_e_r_s or quoting characters
|
||||
listed above may not appear in an alias name. The replacement text may
|
||||
contain any valid shell input, including shell metacharacters. The
|
||||
first word of the replacement text is tested for aliases, but a word
|
||||
that is identical to an alias being expanded is not expanded a second
|
||||
time. This means that one may alias llss to llss --FF, for instance, and
|
||||
bbaasshh does not try to recursively expand the replacement text. If the
|
||||
last character of the alias value is a _b_l_a_n_k, then the next command
|
||||
contain any valid shell input, including shell metacharacters. The
|
||||
first word of the replacement text is tested for aliases, but a word
|
||||
that is identical to an alias being expanded is not expanded a second
|
||||
time. This means that one may alias llss to llss --FF, for instance, and
|
||||
bbaasshh does not try to recursively expand the replacement text. If the
|
||||
last character of the alias value is a _b_l_a_n_k, then the next command
|
||||
word following the alias is also checked for alias expansion.
|
||||
|
||||
Aliases are created and listed with the aalliiaass command, and removed with
|
||||
the uunnaalliiaass command.
|
||||
|
||||
There is no mechanism for using arguments in the replacement text. If
|
||||
arguments are needed, a shell function should be used (see FFUUNNCCTTIIOONNSS
|
||||
There is no mechanism for using arguments in the replacement text. If
|
||||
arguments are needed, a shell function should be used (see FFUUNNCCTTIIOONNSS
|
||||
below).
|
||||
|
||||
Aliases are not expanded when the shell is not interactive, unless the
|
||||
eexxppaanndd__aalliiaasseess shell option is set using sshhoopptt (see the description of
|
||||
Aliases are not expanded when the shell is not interactive, unless the
|
||||
eexxppaanndd__aalliiaasseess shell option is set using sshhoopptt (see the description of
|
||||
sshhoopptt under SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS below).
|
||||
|
||||
The rules concerning the definition and use of aliases are somewhat
|
||||
confusing. BBaasshh always reads at least one complete line of input
|
||||
before executing any of the commands on that line. Aliases are
|
||||
expanded when a command is read, not when it is executed. Therefore,
|
||||
an alias definition appearing on the same line as another command does
|
||||
not take effect until the next line of input is read. The commands
|
||||
The rules concerning the definition and use of aliases are somewhat
|
||||
confusing. BBaasshh always reads at least one complete line of input
|
||||
before executing any of the commands on that line. Aliases are
|
||||
expanded when a command is read, not when it is executed. Therefore,
|
||||
an alias definition appearing on the same line as another command does
|
||||
not take effect until the next line of input is read. The commands
|
||||
following the alias definition on that line are not affected by the new
|
||||
alias. This behavior is also an issue when functions are executed.
|
||||
Aliases are expanded when a function definition is read, not when the
|
||||
function is executed, because a function definition is itself a com-
|
||||
mand. As a consequence, aliases defined in a function are not avail-
|
||||
able until after that function is executed. To be safe, always put
|
||||
alias definitions on a separate line, and do not use aalliiaass in compound
|
||||
alias. This behavior is also an issue when functions are executed.
|
||||
Aliases are expanded when a function definition is read, not when the
|
||||
function is executed, because a function definition is itself a com-
|
||||
mand. As a consequence, aliases defined in a function are not avail-
|
||||
able until after that function is executed. To be safe, always put
|
||||
alias definitions on a separate line, and do not use aalliiaass in compound
|
||||
commands.
|
||||
|
||||
For almost every purpose, aliases are superseded by shell functions.
|
||||
|
||||
FFUUNNCCTTIIOONNSS
|
||||
A shell function, defined as described above under SSHHEELLLL GGRRAAMMMMAARR,
|
||||
stores a series of commands for later execution. When the name of a
|
||||
shell function is used as a simple command name, the list of commands
|
||||
A shell function, defined as described above under SSHHEELLLL GGRRAAMMMMAARR,
|
||||
stores a series of commands for later execution. When the name of a
|
||||
shell function is used as a simple command name, the list of commands
|
||||
associated with that function name is executed. Functions are executed
|
||||
in the context of the current shell; no new process is created to
|
||||
interpret them (contrast this with the execution of a shell script).
|
||||
When a function is executed, the arguments to the function become the
|
||||
in the context of the current shell; no new process is created to
|
||||
interpret them (contrast this with the execution of a shell script).
|
||||
When a function is executed, the arguments to the function become the
|
||||
positional parameters during its execution. The special parameter ## is
|
||||
updated to reflect the change. Special parameter 00 is unchanged. The
|
||||
first element of the FFUUNNCCNNAAMMEE variable is set to the name of the func-
|
||||
updated to reflect the change. Special parameter 00 is unchanged. The
|
||||
first element of the FFUUNNCCNNAAMMEE variable is set to the name of the func-
|
||||
tion while the function is executing.
|
||||
|
||||
All other aspects of the shell execution environment are identical
|
||||
between a function and its caller with these exceptions: the DDEEBBUUGG and
|
||||
RREETTUURRNN traps (see the description of the ttrraapp builtin under SSHHEELLLL
|
||||
BBUUIILLTTIINN CCOOMMMMAANNDDSS below) are not inherited unless the function has been
|
||||
given the ttrraaccee attribute (see the description of the ddeeccllaarree builtin
|
||||
below) or the --oo ffuunnccttrraaccee shell option has been enabled with the sseett
|
||||
builtin (in which case all functions inherit the DDEEBBUUGG and RREETTUURRNN
|
||||
traps), and the EERRRR trap is not inherited unless the --oo eerrrrttrraaccee shell
|
||||
All other aspects of the shell execution environment are identical
|
||||
between a function and its caller with these exceptions: the DDEEBBUUGG and
|
||||
RREETTUURRNN traps (see the description of the ttrraapp builtin under SSHHEELLLL
|
||||
BBUUIILLTTIINN CCOOMMMMAANNDDSS below) are not inherited unless the function has been
|
||||
given the ttrraaccee attribute (see the description of the ddeeccllaarree builtin
|
||||
below) or the --oo ffuunnccttrraaccee shell option has been enabled with the sseett
|
||||
builtin (in which case all functions inherit the DDEEBBUUGG and RREETTUURRNN
|
||||
traps), and the EERRRR trap is not inherited unless the --oo eerrrrttrraaccee shell
|
||||
option has been enabled.
|
||||
|
||||
Variables local to the function may be declared with the llooccaall builtin
|
||||
Variables local to the function may be declared with the llooccaall builtin
|
||||
command. Ordinarily, variables and their values are shared between the
|
||||
function and its caller.
|
||||
function and its caller. If a variable is declared llooccaall, the vari-
|
||||
able's visible scope is restricted to that function and its children
|
||||
(including the functions it calls). Local variables "shadow" variables
|
||||
with the same name declared at previous scopes. For instance, a local
|
||||
variable declared in a function hides a global variable of the same
|
||||
name: references and assignments refer to the local variable, leaving
|
||||
the global variable unmodified. When the function returns, the global
|
||||
variable is once again visible.
|
||||
|
||||
The shell uses _d_y_n_a_m_i_c _s_c_o_p_i_n_g to control a variable's visibility
|
||||
within functions. With dynamic scoping, visible variables and their
|
||||
values are a result of the sequence of function calls that caused exe-
|
||||
cution to reach the current function. The value of a variable that a
|
||||
function sees depends on its value within its caller, if any, whether
|
||||
that caller is the "global" scope or another shell function. This is
|
||||
also the value that a local variable declaration "shadows", and the
|
||||
value that is restored when the function returns.
|
||||
|
||||
For example, if a variable _v_a_r is declared as local in function _f_u_n_c_1,
|
||||
and _f_u_n_c_1 calls another function _f_u_n_c_2, references to _v_a_r made from
|
||||
within _f_u_n_c_2 will resolve to the local variable _v_a_r from _f_u_n_c_1, shadow-
|
||||
ing any global variable named _v_a_r.
|
||||
|
||||
The FFUUNNCCNNEESSTT variable, if set to a numeric value greater than 0,
|
||||
defines a maximum function nesting level. Function invocations that
|
||||
@@ -2499,7 +2519,9 @@ CCOONNDDIITTIIOONNAALL EEXXPPRREESSSSIIOONNSS
|
||||
binary operators return true if _a_r_g_1 is equal to, not equal to,
|
||||
less than, less than or equal to, greater than, or greater than
|
||||
or equal to _a_r_g_2, respectively. _A_r_g_1 and _a_r_g_2 may be positive
|
||||
or negative integers.
|
||||
or negative integers. When used with the [[[[ command, _A_r_g_1 and
|
||||
_A_r_g_2 are evaluated as arithmetic expressions (see AARRIITTHHMMEETTIICC
|
||||
EEVVAALLUUAATTIIOONN above).
|
||||
|
||||
SSIIMMPPLLEE CCOOMMMMAANNDD EEXXPPAANNSSIIOONN
|
||||
When a simple command is executed, the shell performs the following
|
||||
@@ -2836,9 +2858,11 @@ PPRROOMMPPTTIINNGG
|
||||
When executing interactively, bbaasshh displays the primary prompt PPSS11 when
|
||||
it is ready to read a command, and the secondary prompt PPSS22 when it
|
||||
needs more input to complete a command. BBaasshh displays PPSS00 after it
|
||||
reads a command but before executing it. BBaasshh allows these prompt
|
||||
strings to be customized by inserting a number of backslash-escaped
|
||||
special characters that are decoded as follows:
|
||||
reads a command but before executing it. BBaasshh displays PPSS44 as
|
||||
described above before tracing each command when the --xx option is
|
||||
enabled. BBaasshh allows these prompt strings to be customized by insert-
|
||||
ing a number of backslash-escaped special characters that are decoded
|
||||
as follows:
|
||||
\\aa an ASCII bell character (07)
|
||||
\\dd the date in "Weekday Month Date" format (e.g., "Tue May
|
||||
26")
|
||||
@@ -3369,6 +3393,18 @@ RREEAADDLLIINNEE
|
||||
sshheellll--bbaacckkwwaarrdd--wwoorrdd
|
||||
Move back to the start of the current or previous word. Words
|
||||
are delimited by non-quoted shell metacharacters.
|
||||
pprreevviioouuss--ssccrreeeenn--lliinnee
|
||||
Attempt to move point to the same physical screen column on the
|
||||
previous physical screen line. This will not have the desired
|
||||
effect if the current Readline line does not take up more than
|
||||
one physical line or if point is not greater than the length of
|
||||
the prompt plus the screen width.
|
||||
nneexxtt--ssccrreeeenn--lliinnee
|
||||
Attempt to move point to the same physical screen column on the
|
||||
next physical screen line. This will not have the desired effect
|
||||
if the current Readline line does not take up more than one
|
||||
physical line or if the length of the current Readline line is
|
||||
not greater than the length of the prompt plus the screen width.
|
||||
cclleeaarr--ssccrreeeenn ((CC--ll))
|
||||
Clear the screen leaving the current line at the top of the
|
||||
screen. With an argument, refresh the current line without
|
||||
@@ -5989,4 +6025,4 @@ BBUUGGSS
|
||||
|
||||
|
||||
|
||||
GNU Bash 4.4 2017 February 1 BASH(1)
|
||||
GNU Bash 4.4 2017 March 22 BASH(1)
|
||||
|
||||
Reference in New Issue
Block a user