change expansion for key-value pair compound assignment to associative arrays to split all words before identifying keys and values; controlled by a new shopt option: kvpair_split, enabled by default; new `loadassoc' loadable builtin to load an associative array from a set of key-value arguments

This commit is contained in:
Chet Ramey
2026-08-17 10:09:07 -04:00
parent 9c8a70bc9e
commit 2f7eb80c77
38 changed files with 1083 additions and 1012 deletions
+225 -199
View File
@@ -1615,8 +1615,7 @@ PPAARRAAMMEETTEERRSS
is also accepted; the _s_u_b_s_c_r_i_p_t is ignored.
Associative arrays are created using
ddeeccllaarree --AA _n_a_m_e
.
ddeeccllaarree --AA _n_a_m_e .
Attributes may be specified for an array variable using the ddeeccllaarree and
rreeaaddoonnllyy builtins. Each attribute applies to all members of an array.
@@ -1637,13 +1636,20 @@ PPAARRAAMMEETTEERRSS
When assigning to an associative array, the words in a compound assignment
may be either assignment statements, for which the subscript is required,
or a list of words that is interpreted as a sequence of alternating keys
and values: _n_a_m_e=(( _k_e_y_1 _v_a_l_u_e_1 _k_e_y_2 _v_a_l_u_e_2 ...)). These are treated identi-
cally to _n_a_m_e=(( [_k_e_y_1]=_v_a_l_u_e_1 [_k_e_y_2]=_v_a_l_u_e_2 ...)). The first word in the
and values: _n_a_m_e=(( _k_e_y_1 _v_a_l_u_e_1 _k_e_y_2 _v_a_l_u_e_2 ...)). The first word in the
list determines how the remaining words are interpreted; all assignments in
a list must be of the same type. When using key/value pairs, the keys may
not be missing or empty; a final missing value is treated like the empty
string.
The kkvvppaaiirr__sspplliitt option to the sshhoopptt builtin (see SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
below) determines how the words in a key/value pair assignment list are
treated. If it is enabled, each word in the list undergoes word expan-
sions, including word splitting, before the assignment identifies individ-
ual keys and values. If it is unset, the key/value pairs in the example
above are treated identically to _n_a_m_e=(( [_k_e_y_1]=_v_a_l_u_e_1 [_k_e_y_2]=_v_a_l_u_e_2 ...))
and expanded appropriately.
This syntax is also accepted by the ddeeccllaarree builtin. Individual array ele-
ments may be assigned to using the _n_a_m_e[_s_u_b_s_c_r_i_p_t]=_v_a_l_u_e syntax introduced
above.
@@ -3692,186 +3698,186 @@ RREEAADDLLIINNEE
prefix of the set of possible completions using a different color.
The color definitions are taken from the value of the LLSS__CCOOLLOORRSS en-
vironment variable. If there is a color definition in $$LLSS__CCOOLLOORRSS
for the custom suffix ".readline-colored-completion-prefix", rreeaadd--
lliinnee uses this color for the common prefix instead of its default.
for the custom suffix "readline-colored-completion-prefix", rreeaaddlliinnee
uses this color for the common prefix instead of its default.
ccoolloorreedd--ssttaattss ((OOffff))
If set to OOnn, rreeaaddlliinnee displays possible completions using different
colors to indicate their file type. The color definitions are taken
from the value of the LLSS__CCOOLLOORRSS environment variable.
ccoommmmeenntt--bbeeggiinn (("##"))
The string that the rreeaaddlliinnee iinnsseerrtt--ccoommmmeenntt command inserts. This
The string that the rreeaaddlliinnee iinnsseerrtt--ccoommmmeenntt command inserts. This
command is bound to MM--## in emacs mode and to ## in vi command mode.
ccoommpplleettiioonn--ddiissppllaayy--wwiiddtthh ((--11))
The number of screen columns used to display possible matches when
The number of screen columns used to display possible matches when
performing completion. The value is ignored if it is less than 0 or
greater than the terminal screen width. A value of 0 causes matches
to be displayed one per line. The default value is -1.
ccoommpplleettiioonn--iiggnnoorree--ccaassee ((OOffff))
If set to OOnn, rreeaaddlliinnee performs filename matching and completion in
If set to OOnn, rreeaaddlliinnee performs filename matching and completion in
a case-insensitive fashion.
ccoommpplleettiioonn--mmaapp--ccaassee ((OOffff))
If set to OOnn, and ccoommpplleettiioonn--iiggnnoorree--ccaassee is enabled, rreeaaddlliinnee treats
hyphens (_-) and underscores (__) as equivalent when performing
hyphens (_-) and underscores (__) as equivalent when performing
case-insensitive filename matching and completion.
ccoommpplleettiioonn--pprreeffiixx--ddiissppllaayy--lleennggtthh ((00))
The maximum length in characters of the common prefix of a list of
possible completions that is displayed without modification. When
set to a value greater than zero, rreeaaddlliinnee replaces common prefixes
longer than this value with an ellipsis when displaying possible
completions. If a completion begins with a period, and eeaaddlliinnee is
The maximum length in characters of the common prefix of a list of
possible completions that is displayed without modification. When
set to a value greater than zero, rreeaaddlliinnee replaces common prefixes
longer than this value with an ellipsis when displaying possible
completions. If a completion begins with a period, and eeaaddlliinnee is
completing filenames, it uses three underscores instead of an ellip-
sis.
ccoommpplleettiioonn--qquueerryy--iitteemmss ((110000))
This determines when the user is queried about viewing the number of
possible completions generated by the ppoossssiibbllee--ccoommpplleettiioonnss command.
It may be set to any integer value greater than or equal to zero.
If the number of possible completions is greater than or equal to
the value of this variable, rreeaaddlliinnee asks whether or not the user
wishes to view them; otherwise rreeaaddlliinnee simply lists them on the
terminal. A zero value means rreeaaddlliinnee should never ask; negative
possible completions generated by the ppoossssiibbllee--ccoommpplleettiioonnss command.
It may be set to any integer value greater than or equal to zero.
If the number of possible completions is greater than or equal to
the value of this variable, rreeaaddlliinnee asks whether or not the user
wishes to view them; otherwise rreeaaddlliinnee simply lists them on the
terminal. A zero value means rreeaaddlliinnee should never ask; negative
values are treated as zero.
ccoonnvveerrtt--mmeettaa ((OOnn))
If set to OOnn, rreeaaddlliinnee converts characters it reads that have the
eighth bit set to an ASCII key sequence by clearing the eighth bit
and prefixing it with an escape character (converting the character
to have the meta prefix). The default is _O_n, but rreeaaddlliinnee sets it
If set to OOnn, rreeaaddlliinnee converts characters it reads that have the
eighth bit set to an ASCII key sequence by clearing the eighth bit
and prefixing it with an escape character (converting the character
to have the meta prefix). The default is _O_n, but rreeaaddlliinnee sets it
to _O_f_f if the locale contains characters whose encodings may include
bytes with the eighth bit set. This variable is dependent on the
LLCC__CCTTYYPPEE locale category, and may change if the locale changes.
This variable also affects key bindings; see the description of
bytes with the eighth bit set. This variable is dependent on the
LLCC__CCTTYYPPEE locale category, and may change if the locale changes.
This variable also affects key bindings; see the description of
ffoorrccee--mmeettaa--pprreeffiixx below.
ddiissaabbllee--ccoommpplleettiioonn ((OOffff))
If set to OOnn, rreeaaddlliinnee inhibits word completion. Completion charac-
ters are inserted into the line as if they had been mapped to sseellff--
ters are inserted into the line as if they had been mapped to sseellff--
iinnsseerrtt.
eecchhoo--ccoonnttrrooll--cchhaarraacctteerrss ((OOnn))
When set to OOnn, on operating systems that indicate they support it,
When set to OOnn, on operating systems that indicate they support it,
rreeaaddlliinnee echoes a character corresponding to a signal generated from
the keyboard.
eeddiittiinngg--mmooddee ((eemmaaccss))
Controls whether rreeaaddlliinnee uses a set of key bindings similar to
Controls whether rreeaaddlliinnee uses a set of key bindings similar to
_E_m_a_c_s or _v_i. eeddiittiinngg--mmooddee can be set to either eemmaaccss or vvii.
eemmaaccss--mmooddee--ssttrriinngg ((@@))
If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is dis-
played immediately before the last line of the primary prompt when
emacs editing mode is active. The value is expanded like a key
binding, so the standard set of meta- and control- prefixes and
backslash escape sequences is available. The \1 and \2 escapes be-
gin and end sequences of non-printing characters, which can be used
If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is dis-
played immediately before the last line of the primary prompt when
emacs editing mode is active. The value is expanded like a key
binding, so the standard set of meta- and control- prefixes and
backslash escape sequences is available. The \1 and \2 escapes be-
gin and end sequences of non-printing characters, which can be used
to embed a terminal control sequence into the mode string.
eennaabbllee--aaccttiivvee--rreeggiioonn ((OOnn))
When this variable is set to _O_n, rreeaaddlliinnee allows certain commands to
designate the region as _a_c_t_i_v_e. When the region is active, rreeaaddlliinnee
highlights the text in the region using the value of the aaccttiivvee--rree--
highlights the text in the region using the value of the aaccttiivvee--rree--
ggiioonn--ssttaarrtt--ccoolloorr variable, which defaults to the string that enables
the terminal's standout mode. The active region shows the text in-
the terminal's standout mode. The active region shows the text in-
serted by bracketed-paste and any matching text found by incremental
and non-incremental history searches.
eennaabbllee--bbrraacckkeetteedd--ppaassttee ((OOnn))
When set to OOnn, rreeaaddlliinnee configures the terminal to insert each
paste into the editing buffer as a single string of characters, in-
stead of treating each character as if it had been read from the
When set to OOnn, rreeaaddlliinnee configures the terminal to insert each
paste into the editing buffer as a single string of characters, in-
stead of treating each character as if it had been read from the
keyboard. This is called _b_r_a_c_k_e_t_e_d_-_p_a_s_t_e _m_o_d_e; it prevents rreeaaddlliinnee
from executing any editing commands bound to key sequences appearing
in the pasted text.
eennaabbllee--kkeeyyppaadd ((OOffff))
When set to OOnn, rreeaaddlliinnee tries to enable the application keypad
When set to OOnn, rreeaaddlliinnee tries to enable the application keypad
when it is called. Some systems need this to enable the arrow keys.
eennaabbllee--mmeettaa--kkeeyy ((OOnn))
When set to OOnn, rreeaaddlliinnee tries to enable any meta modifier key the
When set to OOnn, rreeaaddlliinnee tries to enable any meta modifier key the
terminal claims to support. On many terminals, the Meta key is used
to send eight-bit characters; this variable checks for the terminal
to send eight-bit characters; this variable checks for the terminal
capability that indicates the terminal can enable and disable a mode
that sets the eighth bit of a character (0200) if the Meta key is
that sets the eighth bit of a character (0200) if the Meta key is
held down when the character is typed (a meta character).
eexxppaanndd--ttiillddee ((OOffff))
If set to OOnn, rreeaaddlliinnee performs tilde expansion when it attempts
If set to OOnn, rreeaaddlliinnee performs tilde expansion when it attempts
word completion.
ffoorrccee--mmeettaa--pprreeffiixx ((OOffff))
If set to OOnn, rreeaaddlliinnee modifies its behavior when binding key se-
If set to OOnn, rreeaaddlliinnee modifies its behavior when binding key se-
quences containing \M- or Meta- (see KKeeyy BBiinnddiinnggss above) by convert-
ing a key sequence of the form \M-_C or Meta-_C to the two-character
sequence EESSCC _C (adding the meta prefix). If ffoorrccee--mmeettaa--pprreeffiixx is
set to OOffff (the default), rreeaaddlliinnee uses the value of the ccoonn--
vveerrtt--mmeettaa variable to determine whether to perform this conversion:
if ccoonnvveerrtt--mmeettaa is OOnn, rreeaaddlliinnee performs the conversion described
ing a key sequence of the form \M-_C or Meta-_C to the two-character
sequence EESSCC _C (adding the meta prefix). If ffoorrccee--mmeettaa--pprreeffiixx is
set to OOffff (the default), rreeaaddlliinnee uses the value of the ccoonn--
vveerrtt--mmeettaa variable to determine whether to perform this conversion:
if ccoonnvveerrtt--mmeettaa is OOnn, rreeaaddlliinnee performs the conversion described
above; if it is OOffff, rreeaaddlliinnee converts _C to a meta character by set-
ting the eighth bit (0200).
hhiissttoorryy--pprreesseerrvvee--ppooiinntt ((OOffff))
If set to OOnn, the history code attempts to place point at the same
location on each history line retrieved with pprreevviioouuss--hhiissttoorryy or
If set to OOnn, the history code attempts to place point at the same
location on each history line retrieved with pprreevviioouuss--hhiissttoorryy or
nneexxtt--hhiissttoorryy.
hhiissttoorryy--ssiizzee ((uunnsseett))
Set the maximum number of history entries saved in the history list.
If set to zero, any existing history entries are deleted and no new
entries are saved. If set to a value less than zero, the number of
history entries is not limited. By default, bbaasshh sets the maximum
number of history entries to the value of the HHIISSTTSSIIZZEE shell vari-
If set to zero, any existing history entries are deleted and no new
entries are saved. If set to a value less than zero, the number of
history entries is not limited. By default, bbaasshh sets the maximum
number of history entries to the value of the HHIISSTTSSIIZZEE shell vari-
able. Setting _h_i_s_t_o_r_y_-_s_i_z_e to a non-numeric value will set the max-
imum number of history entries to 500.
hhoorriizzoonnttaall--ssccrroollll--mmooddee ((OOffff))
Setting this variable to OOnn makes rreeaaddlliinnee use a single line for
display, scrolling the input horizontally on a single screen line
Setting this variable to OOnn makes rreeaaddlliinnee use a single line for
display, scrolling the input horizontally on a single screen line
when it becomes longer than the screen width rather than wrapping to
a new line. This setting is automatically enabled for terminals of
a new line. This setting is automatically enabled for terminals of
height 1.
iinnppuutt--mmeettaa ((OOffff))
If set to OOnn, rreeaaddlliinnee enables eight-bit input (that is, it does not
clear the eighth bit in the characters it reads), regardless of what
the terminal claims it can support. The default is _O_f_f, but rreeaadd--
the terminal claims it can support. The default is _O_f_f, but rreeaadd--
lliinnee sets it to _O_n if the locale contains characters whose encodings
may include bytes with the eighth bit set. This variable is depen-
dent on the LLCC__CCTTYYPPEE locale category, and its value may change if
may include bytes with the eighth bit set. This variable is depen-
dent on the LLCC__CCTTYYPPEE locale category, and its value may change if
the locale changes. The name mmeettaa--ffllaagg is a synonym for iinnppuutt--mmeettaa.
iisseeaarrcchh--tteerrmmiinnaattoorrss (("CC--[[CC--jj"))
The string of characters that should terminate an incremental search
without subsequently executing the character as a command. If this
without subsequently executing the character as a command. If this
variable has not been given a value, the characters _E_S_C and CC--jj ter-
minate an incremental search.
kkeeyymmaapp ((eemmaaccss))
Set the current rreeaaddlliinnee keymap. The set of valid keymap names is
_e_m_a_c_s_, _e_m_a_c_s_-_s_t_a_n_d_a_r_d_, _e_m_a_c_s_-_m_e_t_a_, _e_m_a_c_s_-_c_t_l_x_, _v_i_, _v_i_-_c_o_m_m_a_n_d, and
_v_i_-_i_n_s_e_r_t. _v_i is equivalent to _v_i_-_c_o_m_m_a_n_d; _e_m_a_c_s is equivalent to
_e_m_a_c_s_-_s_t_a_n_d_a_r_d. The default value is _e_m_a_c_s; the value of eeddiitt--
Set the current rreeaaddlliinnee keymap. The set of valid keymap names is
_e_m_a_c_s_, _e_m_a_c_s_-_s_t_a_n_d_a_r_d_, _e_m_a_c_s_-_m_e_t_a_, _e_m_a_c_s_-_c_t_l_x_, _v_i_, _v_i_-_c_o_m_m_a_n_d, and
_v_i_-_i_n_s_e_r_t. _v_i is equivalent to _v_i_-_c_o_m_m_a_n_d; _e_m_a_c_s is equivalent to
_e_m_a_c_s_-_s_t_a_n_d_a_r_d. The default value is _e_m_a_c_s; the value of eeddiitt--
iinngg--mmooddee also affects the default keymap.
kkeeyysseeqq--ttiimmeeoouutt ((550000))
Specifies the duration rreeaaddlliinnee will wait for a character when read-
ing an ambiguous key sequence (one that can form a complete key se-
quence using the input read so far, or can take additional input to
complete a longer key sequence). If rreeaaddlliinnee does not receive any
input within the timeout, it uses the shorter but complete key se-
quence. The value is specified in milliseconds, so a value of 1000
means that rreeaaddlliinnee will wait one second for additional input. If
this variable is set to a value less than or equal to zero, or to a
non-numeric value, rreeaaddlliinnee waits until another key is pressed to
ing an ambiguous key sequence (one that can form a complete key se-
quence using the input read so far, or can take additional input to
complete a longer key sequence). If rreeaaddlliinnee does not receive any
input within the timeout, it uses the shorter but complete key se-
quence. The value is specified in milliseconds, so a value of 1000
means that rreeaaddlliinnee will wait one second for additional input. If
this variable is set to a value less than or equal to zero, or to a
non-numeric value, rreeaaddlliinnee waits until another key is pressed to
decide which key sequence to complete.
mmaarrkk--ddiirreeccttoorriieess ((OOnn))
If set to OOnn, completed directory names have a slash appended.
mmaarrkk--mmooddiiffiieedd--lliinneess ((OOffff))
If set to OOnn, rreeaaddlliinnee displays history lines that have been modi-
If set to OOnn, rreeaaddlliinnee displays history lines that have been modi-
fied with a preceding asterisk (**).
mmaarrkk--ssyymmlliinnkkeedd--ddiirreeccttoorriieess ((OOffff))
If set to OOnn, completed names which are symbolic links to directo-
ries have a slash appended, subject to the value of mmaarrkk--ddiirreeccttoo--
If set to OOnn, completed names which are symbolic links to directo-
ries have a slash appended, subject to the value of mmaarrkk--ddiirreeccttoo--
rriieess.
mmaattcchh--hhiiddddeenn--ffiilleess ((OOnn))
This variable, when set to OOnn, forces rreeaaddlliinnee to match files whose
This variable, when set to OOnn, forces rreeaaddlliinnee to match files whose
names begin with a "." (hidden files) when performing filename com-
pletion. If set to OOffff, the user must include the leading "." in
pletion. If set to OOffff, the user must include the leading "." in
the filename to be completed.
mmeennuu--ccoommpplleettee--ddiissppllaayy--pprreeffiixx ((OOffff))
If set to OOnn, menu completion displays the common prefix of the list
of possible completions (which may be empty) before cycling through
of possible completions (which may be empty) before cycling through
the list.
oouuttppuutt--mmeettaa ((OOffff))
If set to OOnn, rreeaaddlliinnee displays characters with the eighth bit set
directly rather than as a meta-prefixed escape sequence. The de-
fault is _O_f_f, but rreeaaddlliinnee sets it to _O_n if the locale contains
characters whose encodings may include bytes with the eighth bit
set. This variable is dependent on the LLCC__CCTTYYPPEE locale category,
If set to OOnn, rreeaaddlliinnee displays characters with the eighth bit set
directly rather than as a meta-prefixed escape sequence. The de-
fault is _O_f_f, but rreeaaddlliinnee sets it to _O_n if the locale contains
characters whose encodings may include bytes with the eighth bit
set. This variable is dependent on the LLCC__CCTTYYPPEE locale category,
and its value may change if the locale changes.
ppaaggee--ccoommpplleettiioonnss ((OOnn))
If set to OOnn, rreeaaddlliinnee uses an internal pager resembling _m_o_r_e(1) to
If set to OOnn, rreeaaddlliinnee uses an internal pager resembling _m_o_r_e(1) to
display a screenful of possible completions at a time.
pprreeffeerr--vviissiibbllee--bbeellll
See bbeellll--ssttyyllee.
@@ -3881,92 +3887,92 @@ RREEAADDLLIINNEE
rreevveerrtt--aallll--aatt--nneewwlliinnee ((OOffff))
If set to OOnn, rreeaaddlliinnee will undo all changes to history lines before
returning when executing aacccceepptt--lliinnee. By default, history lines may
be modified and retain individual undo lists across calls to rreeaadd--
be modified and retain individual undo lists across calls to rreeaadd--
lliinnee.
sseeaarrcchh--iiggnnoorree--ccaassee ((OOffff))
If set to OOnn, rreeaaddlliinnee performs incremental and non-incremental his-
tory list searches in a case-insensitive fashion.
sshhooww--aallll--iiff--aammbbiigguuoouuss ((OOffff))
This alters the default behavior of the completion functions. If
set to OOnn, words which have more than one possible completion cause
This alters the default behavior of the completion functions. If
set to OOnn, words which have more than one possible completion cause
the matches to be listed immediately instead of ringing the bell.
sshhooww--aallll--iiff--uunnmmooddiiffiieedd ((OOffff))
This alters the default behavior of the completion functions in a
This alters the default behavior of the completion functions in a
fashion similar to sshhooww--aallll--iiff--aammbbiigguuoouuss. If set to OOnn, words which
have more than one possible completion without any possible partial
completion (the possible completions don't share a common prefix)
cause the matches to be listed immediately instead of ringing the
have more than one possible completion without any possible partial
completion (the possible completions don't share a common prefix)
cause the matches to be listed immediately instead of ringing the
bell.
sshhooww--mmooddee--iinn--pprroommpptt ((OOffff))
If set to OOnn, add a string to the beginning of the prompt indicating
the editing mode: emacs, vi command, or vi insertion. The mode
the editing mode: emacs, vi command, or vi insertion. The mode
strings are user-settable (e.g., _e_m_a_c_s_-_m_o_d_e_-_s_t_r_i_n_g).
sskkiipp--ccoommpplleetteedd--tteexxtt ((OOffff))
If set to OOnn, this alters the default completion behavior when in-
serting a single match into the line. It's only active when per-
forming completion in the middle of a word. If enabled, rreeaaddlliinnee
If set to OOnn, this alters the default completion behavior when in-
serting a single match into the line. It's only active when per-
forming completion in the middle of a word. If enabled, rreeaaddlliinnee
does not insert characters from the completion that match characters
after point in the word being completed, so portions of the word
after point in the word being completed, so portions of the word
following the cursor are not duplicated.
vvii--ccmmdd--mmooddee--ssttrriinngg ((((ccmmdd))))
If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is dis-
played immediately before the last line of the primary prompt when
vi editing mode is active and in command mode. The value is ex-
panded like a key binding, so the standard set of meta- and control-
prefixes and backslash escape sequences is available. The \1 and \2
escapes begin and end sequences of non-printing characters, which
can be used to embed a terminal control sequence into the mode
string.
vvii--iinnss--mmooddee--ssttrriinngg ((((iinnss))))
If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is dis-
played immediately before the last line of the primary prompt when
vi editing mode is active and in insertion mode. The value is ex-
vi editing mode is active and in command mode. The value is ex-
panded like a key binding, so the standard set of meta- and control-
prefixes and backslash escape sequences is available. The \1 and \2
escapes begin and end sequences of non-printing characters, which
can be used to embed a terminal control sequence into the mode
string.
vvii--iinnss--mmooddee--ssttrriinngg ((((iinnss))))
If the _s_h_o_w_-_m_o_d_e_-_i_n_-_p_r_o_m_p_t variable is enabled, this string is dis-
played immediately before the last line of the primary prompt when
vi editing mode is active and in insertion mode. The value is ex-
panded like a key binding, so the standard set of meta- and control-
prefixes and backslash escape sequences is available. The \1 and \2
escapes begin and end sequences of non-printing characters, which
can be used to embed a terminal control sequence into the mode
string.
vviissiibbllee--ssttaattss ((OOffff))
If set to OOnn, a character denoting a file's type as reported by
_s_t_a_t(2) is appended to the filename when listing possible comple-
If set to OOnn, a character denoting a file's type as reported by
_s_t_a_t(2) is appended to the filename when listing possible comple-
tions.
RReeaaddlliinnee CCoonnddiittiioonnaall CCoonnssttrruuccttss
RReeaaddlliinnee implements a facility similar in spirit to the conditional compi-
lation features of the C preprocessor which allows key bindings and vari-
able settings to be performed as the result of tests. There are four
RReeaaddlliinnee implements a facility similar in spirit to the conditional compi-
lation features of the C preprocessor which allows key bindings and vari-
able settings to be performed as the result of tests. There are four
parser directives available.
$$iiff The $$iiff construct allows bindings to be made based on the editing
mode, the terminal being used, or the application using rreeaaddlliinnee.
The text of the test, after any comparison operator, extends to the
end of the line; unless otherwise noted, no characters are required
$$iiff The $$iiff construct allows bindings to be made based on the editing
mode, the terminal being used, or the application using rreeaaddlliinnee.
The text of the test, after any comparison operator, extends to the
end of the line; unless otherwise noted, no characters are required
to isolate it.
mmooddee The mmooddee== form of the $$iiff directive is used to test whether
rreeaaddlliinnee is in emacs or vi mode. This may be used in con-
junction with the sseett kkeeyymmaapp command, for instance, to set
mmooddee The mmooddee== form of the $$iiff directive is used to test whether
rreeaaddlliinnee is in emacs or vi mode. This may be used in con-
junction with the sseett kkeeyymmaapp command, for instance, to set
bindings in the _e_m_a_c_s_-_s_t_a_n_d_a_r_d and _e_m_a_c_s_-_c_t_l_x keymaps only if
rreeaaddlliinnee is starting out in emacs mode.
tteerrmm The tteerrmm== form may be used to include terminal-specific key
bindings, perhaps to bind the key sequences output by the
terminal's function keys. The word on the right side of the
== is tested against both the full name of the terminal and
the portion of the terminal name before the first --. This
allows _x_t_e_r_m to match both _x_t_e_r_m and _x_t_e_r_m_-_2_5_6_c_o_l_o_r, for in-
tteerrmm The tteerrmm== form may be used to include terminal-specific key
bindings, perhaps to bind the key sequences output by the
terminal's function keys. The word on the right side of the
== is tested against both the full name of the terminal and
the portion of the terminal name before the first --. This
allows _x_t_e_r_m to match both _x_t_e_r_m and _x_t_e_r_m_-_2_5_6_c_o_l_o_r, for in-
stance.
vveerrssiioonn
The vveerrssiioonn test may be used to perform comparisons against
specific rreeaaddlliinnee versions. The vveerrssiioonn expands to the cur-
rent rreeaaddlliinnee version. The set of comparison operators in-
The vveerrssiioonn test may be used to perform comparisons against
specific rreeaaddlliinnee versions. The vveerrssiioonn expands to the cur-
rent rreeaaddlliinnee version. The set of comparison operators in-
cludes ==, (and ====), !!==, <<==, >>==, <<, and >>. The version number
supplied on the right side of the operator consists of a ma-
jor version number, an optional decimal point, and an op-
tional minor version (e.g., 77..11). If the minor version is
omitted, it defaults to 00. The operator may be separated
from the string vveerrssiioonn and from the version number argument
supplied on the right side of the operator consists of a ma-
jor version number, an optional decimal point, and an op-
tional minor version (e.g., 77..11). If the minor version is
omitted, it defaults to 00. The operator may be separated
from the string vveerrssiioonn and from the version number argument
by whitespace.
_a_p_p_l_i_c_a_t_i_o_n
@@ -3974,8 +3980,8 @@ RREEAADDLLIINNEE
cific settings. Each program using the rreeaaddlliinnee library sets
the _a_p_p_l_i_c_a_t_i_o_n _n_a_m_e, and an initialization file can test for
a particular value. This could be used to bind key sequences
to functions useful for a specific program. For instance,
the following command adds a key sequence that quotes the
to functions useful for a specific program. For instance,
the following command adds a key sequence that quotes the
current or previous word in bbaasshh:
$$iiff Bash
@@ -3984,83 +3990,83 @@ RREEAADDLLIINNEE
$$eennddiiff
_v_a_r_i_a_b_l_e
The _v_a_r_i_a_b_l_e construct provides simple equality tests for
rreeaaddlliinnee variables and values. The permitted comparison op-
erators are _=, _=_=, and _!_=. The variable name must be sepa-
rated from the comparison operator by whitespace; the opera-
The _v_a_r_i_a_b_l_e construct provides simple equality tests for
rreeaaddlliinnee variables and values. The permitted comparison op-
erators are _=, _=_=, and _!_=. The variable name must be sepa-
rated from the comparison operator by whitespace; the opera-
tor may be separated from the value on the right hand side by
whitespace. String and boolean variables may be tested.
Boolean variables must be tested against the values _o_n and
whitespace. String and boolean variables may be tested.
Boolean variables must be tested against the values _o_n and
_o_f_f.
$$eellssee Commands in this branch of the $$iiff directive are executed if the
$$eellssee Commands in this branch of the $$iiff directive are executed if the
test fails.
$$eennddiiff
This command, as seen in the previous example, terminates an $$iiff
This command, as seen in the previous example, terminates an $$iiff
command.
$$iinncclluuddee
This directive takes a single filename as an argument and reads com-
mands and key bindings from that file. For example, the following
mands and key bindings from that file. For example, the following
directive would read _/_e_t_c_/_i_n_p_u_t_r_c:
$$iinncclluuddee _/_e_t_c_/_i_n_p_u_t_r_c
SSeeaarrcchhiinngg
RReeaaddlliinnee provides commands for searching through the command history (see
HHIISSTTOORRYY below) for lines containing a specified string. There are two
RReeaaddlliinnee provides commands for searching through the command history (see
HHIISSTTOORRYY below) for lines containing a specified string. There are two
search modes: _i_n_c_r_e_m_e_n_t_a_l and _n_o_n_-_i_n_c_r_e_m_e_n_t_a_l.
Incremental searches begin before the user has finished typing the search
Incremental searches begin before the user has finished typing the search
string. As each character of the search string is typed, rreeaaddlliinnee displays
the next entry from the history matching the string typed so far. An in-
the next entry from the history matching the string typed so far. An in-
cremental search requires only as many characters as needed to find the de-
sired history entry. When using emacs editing mode, type CC--rr to search
backward in the history for a particular string. Typing CC--ss searches for-
ward through the history. The characters present in the value of the
iisseeaarrcchh--tteerrmmiinnaattoorrss variable are used to terminate an incremental search.
If that variable has not been assigned a value, _E_S_C and CC--jj terminate an
incremental search. CC--gg aborts an incremental search and restores the
sired history entry. When using emacs editing mode, type CC--rr to search
backward in the history for a particular string. Typing CC--ss searches for-
ward through the history. The characters present in the value of the
iisseeaarrcchh--tteerrmmiinnaattoorrss variable are used to terminate an incremental search.
If that variable has not been assigned a value, _E_S_C and CC--jj terminate an
incremental search. CC--gg aborts an incremental search and restores the
original line. When the search is terminated, the history entry containing
the search string becomes the current line.
To find other matching entries in the history list, type CC--rr or CC--ss as ap-
propriate. This searches backward or forward in the history for the next
entry matching the search string typed so far. Any other key sequence
bound to a rreeaaddlliinnee command terminates the search and executes that com-
mand. For instance, a newline terminates the search and accepts the line,
thereby executing the command from the history list. A movement command
will terminate the search, make the last line found the current line, and
To find other matching entries in the history list, type CC--rr or CC--ss as ap-
propriate. This searches backward or forward in the history for the next
entry matching the search string typed so far. Any other key sequence
bound to a rreeaaddlliinnee command terminates the search and executes that com-
mand. For instance, a newline terminates the search and accepts the line,
thereby executing the command from the history list. A movement command
will terminate the search, make the last line found the current line, and
begin editing.
RReeaaddlliinnee remembers the last incremental search string. If two CC--rrs are
typed without any intervening characters defining a new search string,
RReeaaddlliinnee remembers the last incremental search string. If two CC--rrs are
typed without any intervening characters defining a new search string,
rreeaaddlliinnee uses any remembered search string.
Non-incremental searches read the entire search string before starting to
Non-incremental searches read the entire search string before starting to
search for matching history entries. The search string may be typed by the
user or be part of the contents of the current line.
RReeaaddlliinnee CCoommmmaanndd NNaammeess
The following is a list of the names of the commands and the default key
sequences to which they are bound. Command names without an accompanying
The following is a list of the names of the commands and the default key
sequences to which they are bound. Command names without an accompanying
key sequence are unbound by default.
In the following descriptions, _p_o_i_n_t refers to the current cursor position,
and _m_a_r_k refers to a cursor position saved by the sseett--mmaarrkk command. The
and _m_a_r_k refers to a cursor position saved by the sseett--mmaarrkk command. The
text between the point and mark is referred to as the _r_e_g_i_o_n. RReeaaddlliinnee has
the concept of an _a_c_t_i_v_e _r_e_g_i_o_n: when the region is active, rreeaaddlliinnee redis-
play highlights the region using the value of the aaccttiivvee--rreeggiioonn--ssttaarrtt--ccoolloorr
variable. The eennaabbllee--aaccttiivvee--rreeggiioonn rreeaaddlliinnee variable turns this on and
variable. The eennaabbllee--aaccttiivvee--rreeggiioonn rreeaaddlliinnee variable turns this on and
off. Several commands set the region to active; those are noted below.
CCoommmmaannddss ffoorr MMoovviinngg
bbeeggiinnnniinngg--ooff--lliinnee ((CC--aa))
Move to the start of the current line. This may also be bound to
Move to the start of the current line. This may also be bound to
the Home key on some keyboards.
eenndd--ooff--lliinnee ((CC--ee))
Move to the end of the line. This may also be bound to the End key
Move to the end of the line. This may also be bound to the End key
on some keyboards.
ffoorrwwaarrdd--cchhaarr ((CC--ff))
Move forward a character. This may also be bound to the right arrow
@@ -4072,32 +4078,32 @@ RREEAADDLLIINNEE
Move forward to the end of the next word. Words are composed of al-
phanumeric characters (letters and digits).
bbaacckkwwaarrdd--wwoorrdd ((MM--bb))
Move back to the start of the current or previous word. Words are
Move back to the start of the current or previous word. Words are
composed of alphanumeric characters (letters and digits).
sshheellll--ffoorrwwaarrdd--wwoorrdd ((MM--CC--ff))
Move forward to the end of the next word. Words are delimited by
Move forward to the end of the next word. Words are delimited by
non-quoted shell metacharacters.
sshheellll--bbaacckkwwaarrdd--wwoorrdd ((MM--CC--bb))
Move back to the start of the current or previous word. Words are
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 pre-
vious physical screen line. This will not have the desired effect
vious physical screen line. This will not have the desired effect
if the current rreeaaddlliinnee line does not take up more than one physical
line or if point is not greater than the length of the prompt plus
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 rreeaaddlliinnee line does not take up more than one physical line
or if the length of the current rreeaaddlliinnee line is not greater than
physical screen line. This will not have the desired effect if the
current rreeaaddlliinnee line does not take up more than one physical line
or if the length of the current rreeaaddlliinnee line is not greater than
the length of the prompt plus the screen width.
cclleeaarr--ddiissppllaayy ((MM--CC--ll))
Clear the screen and, if possible, the terminal's scrollback buffer,
then redraw the current line, leaving the current line at the top of
the screen.
cclleeaarr--ssccrreeeenn ((CC--ll))
Clear the screen, then redraw the current line, leaving the current
Clear the screen, then redraw the current line, leaving the current
line at the top of the screen. With a numeric argument, refresh the
current line without clearing the screen.
rreeddrraaww--ccuurrrreenntt--lliinnee
@@ -4105,16 +4111,16 @@ RREEAADDLLIINNEE
CCoommmmaannddss ffoorr MMaanniippuullaattiinngg tthhee HHiissttoorryy
aacccceepptt--lliinnee ((NNeewwlliinnee,, RReettuurrnn))
Accept the line regardless of where the cursor is. If this line is
non-empty, add it to the history list according to the state of the
HHIISSTTCCOONNTTRROOLL and HHIISSTTIIGGNNOORREE variables. If the line is a modified
Accept the line regardless of where the cursor is. If this line is
non-empty, add it to the history list according to the state of the
HHIISSTTCCOONNTTRROOLL and HHIISSTTIIGGNNOORREE variables. If the line is a modified
history line, restore the history line to its original state.
pprreevviioouuss--hhiissttoorryy ((CC--pp))
Fetch the previous command from the history list, moving back in the
list. This may also be bound to the up arrow key on some keyboards.
nneexxtt--hhiissttoorryy ((CC--nn))
Fetch the next command from the history list, moving forward in the
list. This may also be bound to the down arrow key on some key-
Fetch the next command from the history list, moving forward in the
list. This may also be bound to the down arrow key on some key-
boards.
bbeeggiinnnniinngg--ooff--hhiissttoorryy ((MM--<<))
Move to the first line in the history.
@@ -4122,31 +4128,43 @@ RREEAADDLLIINNEE
Move to the end of the input history, i.e., the line currently being
entered.
ooppeerraattee--aanndd--ggeett--nneexxtt ((CC--oo))
Accept the current line for execution as if a newline had been en-
Accept the current line for execution as if a newline had been en-
tered, and fetch the next line relative to the current line from the
history for editing. A numeric argument, if supplied, specifies the
history entry to use instead of the current line.
ffeettcchh--hhiissttoorryy
With a numeric argument, fetch that entry from the history list and
make it the current line. Without an argument, move back to the
With a numeric argument, fetch that entry from the history list and
make it the current line. Without an argument, move back to the
first entry in the history list.
rreevveerrssee--sseeaarrcchh--hhiissttoorryy ((CC--rr))
Search backward starting at the current line and moving "up" through
the history as necessary. This is an incremental search. This com-
mand sets the region to the matched text and activates the region.
ffoorrwwaarrdd--sseeaarrcchh--hhiissttoorryy ((CC--ss))
Search forward starting at the current line and moving "down"
through the history as necessary. This is an incremental search.
This command sets the region to the matched text and activates the
Search forward starting at the current line and moving "down"
through the history as necessary. This is an incremental search.
This command sets the region to the matched text and activates the
region.
nnoonn--iinnccrreemmeennttaall--rreevveerrssee--sseeaarrcchh--hhiissttoorryy ((MM--pp))
Search backward through the history starting at the current line us-
ing a non-incremental search for a string supplied by the user. The
search string may match anywhere in a history line.
nnoonn--iinnccrreemmeennttaall--ffoorrwwaarrdd--sseeaarrcchh--hhiissttoorryy ((MM--nn))
Search forward through the history using a non-incremental search
for a string supplied by the user. The search string may match any-
where in a history line.
Search forward through the history starting at the current line us-
ing a non-incremental search for a string supplied by the user. The
search string may match anywhere in a history line.
nnoonn--iinnccrreemmeennttaall--rreevveerrssee--sseeaarrcchh--hhiissttoorryy--aaggaaiinn (())
Search backward through the history starting at the current line us-
ing a non-incremental search for the last non-incremental search
string used. If there is no previous search string, this command
returns an error. The search string may match anywhere in a history
line.
nnoonn--iinnccrreemmeennttaall--ffoorrwwaarrdd--sseeaarrcchh--hhiissttoorryy--aaggaaiinn (())
Search forward through the history starting at the current line us-
ing a non-incremental search for the last non-incremental search
string used. If there is no previous search string, this command
returns an error. The search string may match anywhere in a history
line.
hhiissttoorryy--sseeaarrcchh--bbaacckkwwaarrdd
Search backward through the history for the string of characters be-
tween the start of the current line and the point. The search
@@ -6681,6 +6699,14 @@ SSHHEELLLL BBUUIILLTTIINN CCOOMMMMAANNDDSS
word and all remaining characters on that line to be ig-
nored, as in a non-interactive shell (see CCOOMMMMEENNTTSS above).
This option is enabled by default.
kkvvppaaiirr__sspplliitt
If set, a compound assignment to an associative array per-
forms word expansions, including word splitting, on all
words in the assignment before identifying keys and values.
If it is unset, each word in the compound assignment list is
identified as a key or value before performing the appropri-
ate word expansions, and word splitting is not performed.
This option is enabled by default.
llaassttppiippee
If set, and job control is not active, the shell runs the
last command of a pipeline not executed in the background in
@@ -7373,4 +7399,4 @@ BBUUGGSS
Array variables may not (yet) be exported.
GNU Bash 5.3 2026 July 1 _B_A_S_H(1)
GNU Bash 5.3 2026 August 14 _B_A_S_H(1)