fix the expansion of $@ on the rhs of an assignment statement to be more consistent; fix mapfile to only look up the variable again if a callback is invoked; fix memory leak when converting a variable to an array

This commit is contained in:
Chet Ramey
2026-06-08 10:31:31 -04:00
parent 1e9f5e10b2
commit 8085ee1396
17 changed files with 2589 additions and 2474 deletions
+34
View File
@@ -12993,3 +12993,37 @@ builtins/mapfile.def
state, or even unset it, so we use bind_array_variable to look it
up again every time through the loop
Report and patch from Philippe Grégoire <git@pgregoire.xyz>
5/29
----
subst.c
- string_list_pos_params: make $@ on the rhs of an assignment
statement (quoted or unquoted) behave consistently whether it's a
`standalone' expansion or part of a different word expansion
(e.g., ${@} vs. ${@:1}). This expands consistently to the
positional parameters separated by a space instead of using the
first character of IFS when the expansion is quoted (like "$*").
Report and fix from Emanuele Torre <torreemanuele6@gmail.com>
6/1
---
builtins/break.def
- check_loop_level: if SELECT_COMMAND is defined, add `select' to
the no-loop error message
Report from Keith Thompson <Keith.S.Thompson@gmail.com>
6/4
---
builtins/mapfile.def
- mapfile: only call bind_array_variable if we actually run the
callback; use the old method of calling bind_array_element
otherwise
Report and patch from Grisha Levit <grishalevit@gmail.com>
variables.c, variables.h
- dispose_variable_value is now a public function
arrayfunc.c
- convert_var_to_{array,assoc}: only save the old value if the variable
isn't an array; dispose old value appropriately
Report and patch from Grisha Levit <grishalevit@gmail.com>
+8 -7
View File
@@ -69,7 +69,7 @@ const char * const bash_badsub_errmsg = N_("bad array subscript");
/* **************************************************************** */
/* Convert a shell variable to an array variable. The original value is
saved as array[0]. */
saved as array[0] if the variable is not already an array. */
SHELL_VAR *
convert_var_to_array (SHELL_VAR *var)
{
@@ -78,10 +78,10 @@ convert_var_to_array (SHELL_VAR *var)
oldval = value_cell (var);
array = array_create ();
if (oldval)
if (oldval && array_p (var) == 0 && assoc_p (var) == 0)
array_insert (array, 0, oldval);
FREE (value_cell (var));
dispose_variable_value (var);
var_setarray (var, array);
/* these aren't valid anymore */
@@ -110,8 +110,9 @@ convert_var_to_array (SHELL_VAR *var)
return var;
}
/* Convert a shell variable to an array variable. The original value is
saved as array[0]. */
/* Convert a shell variable to an associative array variable.
The original value is saved as array[0] if the variable is not already
an array. */
SHELL_VAR *
convert_var_to_assoc (SHELL_VAR *var)
{
@@ -120,10 +121,10 @@ convert_var_to_assoc (SHELL_VAR *var)
oldval = value_cell (var);
hash = assoc_create (0);
if (oldval)
if (oldval && array_p (var) == 0 && assoc_p (var) == 0)
assoc_insert (hash, savestring ("0"), oldval);
FREE (value_cell (var));
dispose_variable_value (var);
var_setassoc (var, hash);
/* these aren't valid anymore */
+4
View File
@@ -142,7 +142,11 @@ check_loop_level (void)
{
#if defined (BREAK_COMPLAINS)
if (loop_level == 0 && posixly_correct == 0)
# if defined (SELECT_COMMAND)
builtin_error (_("only meaningful in a `for', `while', `until', or `select' loop"));
# else
builtin_error (_("only meaningful in a `for', `while', or `until' loop"));
# endif
#endif /* BREAK_COMPLAINS */
return (loop_level);
+10 -10
View File
@@ -2,7 +2,7 @@ This file is mapfile.def, from which is created mapfile.c.
It implements the builtin "mapfile" in Bash.
Copyright (C) 2005-2006 Rocky Bernstein for Free Software Foundation, Inc.
Copyright (C) 2008-2024 Free Software Foundation, Inc.
Copyright (C) 2008-2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -197,16 +197,16 @@ mapfile (int fd, long line_count_goal, long origin, long nskip, long callback_qu
zsyncfd (fd);
run_callback (callback, array_index, line);
/* Bad things can happen if the callback modifies ENTRY, e.g.,
unsetting it or changing it to a non-indexed-array type, so we
look it up again every time we need to assign something */
entry = bind_array_variable (array_name, array_index, line, 0);
if (entry == 0 || ASSIGN_DISALLOWED (entry, 0))
return EXECUTION_FAILURE;
}
/* Bad things can happen if the callback modifies ENTRY, e.g.,
unsetting it or changing it to a non-indexed-array type, so we
look it up again every time we need to assign something */
entry = bind_array_variable (array_name, array_index, line, 0);
if (entry == 0 || ASSIGN_DISALLOWED (entry, 0))
return EXECUTION_FAILURE;
bind_array_element (entry, array_index, line, 0);
else
bind_array_element (entry, array_index, line, 0);
/* Have we exceeded # of lines to store? */
line_count++;
+2148 -2143
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -6632,7 +6632,8 @@ A backslash.
Begin a sequence of non-printing characters, which could be used to
embed a terminal control sequence into the prompt.
This escape is only useful when the prompt will be supplied to
\fBreadline\fP, so it shouldn't be used in \fBPS0\fP or \fBPS4\fP.
\fBreadline\fP, so it shouldn't be used in \fBPS0\fP or \fBPS4\fP
or when line editing is not enabled.
.TP
.B \e]
End a sequence of non-printing characters begun with
+152 -147
View File
@@ -1,9 +1,9 @@
This is bash.info, produced by makeinfo version 7.2 from bashref.texi.
This is bash.info, produced by makeinfo version 7.3 from bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 29 April 2026).
Bash shell (version 5.3, 18 May 2026).
This is Edition 5.3, last updated 29 April 2026, of The GNU Bash
This is Edition 5.3, last updated 18 May 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Copyright © 1988-2026 Free Software Foundation, Inc.
@@ -26,10 +26,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 29 April 2026). The Bash home page is
Bash shell (version 5.3, 18 May 2026). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 29 April 2026, of The GNU Bash
This is Edition 5.3, last updated 18 May 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -2465,8 +2465,8 @@ expressions that evaluate to 0. Arithmetic expansions may be nested.
The evaluation is performed according to the rules listed below
(*note Shell Arithmetic::). If the expression is invalid, Bash prints a
message indicating failure to the standard error, does not perform the
substitution, and does not execute the command associated with the
expansion.
substitution, and does not continue to execute the command in which the
error occurs.

File: bash.info, Node: Process Substitution, Next: Word Splitting, Prev: Arithmetic Expansion, Up: Shell Expansions
@@ -2479,8 +2479,9 @@ to using a filename. It takes the form of
<(LIST)
or
>(LIST)
The process LIST is run asynchronously, and its input or output appears
as a filename. This filename is passed as an argument to the current
The process LIST, as long as it is not a null command without
redirections, is run asynchronously, and its input or output appears as
a filename. This filename is passed as an argument to the current
command as the result of the expansion.
If the >(LIST) form is used, writing to the file provides input for
@@ -2911,9 +2912,9 @@ If WORD is unquoted, DELIMITER is WORD itself, and the here-document
text is treated similarly to a double-quoted string: all lines of the
here-document are subjected to parameter expansion, command
substitution, and arithmetic expansion, the character sequence
\newline is treated literally, and \ must be used to quote the
characters \, $, and `; however, double quote characters have no
special meaning.
\newline is treated as a line continuation, and \ must be used to
quote the characters \, $, and `; however, double quote characters
have no special meaning.
If the redirection operator is <<-, the shell strips leading tab
characters from input lines and the line containing DELIMITER. This
@@ -7621,9 +7622,13 @@ can appear in the prompt variables PS0, PS1, PS2, and PS4
A backslash.
\[
Begin a sequence of non-printing characters. This could be used to
embed a terminal control sequence into the prompt.
embed a terminal control sequence into the prompt. This escape is
only useful when the prompt will be supplied to Readline, so it
shouldn't be used in PS0 or PS4, or when line editing is not
enabled.
\]
End a sequence of non-printing characters.
End a sequence of non-printing characters begun with \[
The command number and the history number are usually different: the
history number of a command is its position in the history list, which
@@ -13679,7 +13684,7 @@ D.5 Concept Index
* history list: Bash History Facilities.
(line 6)
* History, how to use: A Programmable Completion Example.
(line 113)
(line 112)
* identifier: Definitions. (line 55)
* initialization file, readline: Readline Init File. (line 6)
* installation: Basic Installation. (line 6)
@@ -13729,7 +13734,7 @@ D.5 Concept Index
* quoting: Quoting. (line 6)
* quoting, ANSI: ANSI-C Quoting. (line 6)
* Readline, how to use: Job Control Variables.
(line 23)
(line 22)
* redirection: Redirections. (line 6)
* reserved word: Definitions. (line 74)
* reserved words: Reserved Words. (line 6)
@@ -13763,138 +13768,138 @@ D.5 Concept Index

Tag Table:
Node: Top895
Node: Introduction2830
Node: What is Bash?3043
Node: What is a shell?4176
Node: Definitions6786
Node: Basic Shell Features10113
Node: Shell Syntax11337
Node: Shell Operation12364
Node: Quoting13655
Node: Escape Character14993
Node: Single Quotes15528
Node: Double Quotes15877
Node: ANSI-C Quoting17222
Node: Locale Translation18616
Node: Creating Internationalized Scripts20019
Node: Comments24217
Node: Shell Commands24984
Node: Reserved Words25923
Node: Simple Commands27066
Node: Pipelines27728
Node: Lists30984
Node: Compound Commands32933
Node: Looping Constructs33942
Node: Conditional Constructs36491
Node: Command Grouping51788
Node: Coprocesses53280
Node: GNU Parallel55966
Node: Shell Functions56884
Node: Shell Parameters65332
Node: Positional Parameters70233
Node: Special Parameters71323
Node: Shell Expansions74784
Node: Brace Expansion76973
Node: Tilde Expansion80309
Node: Shell Parameter Expansion83264
Node: Command Substitution104112
Node: Arithmetic Expansion107963
Node: Top891
Node: Introduction2822
Node: What is Bash?3035
Node: What is a shell?4168
Node: Definitions6778
Node: Basic Shell Features10105
Node: Shell Syntax11329
Node: Shell Operation12356
Node: Quoting13647
Node: Escape Character14985
Node: Single Quotes15520
Node: Double Quotes15869
Node: ANSI-C Quoting17214
Node: Locale Translation18608
Node: Creating Internationalized Scripts20011
Node: Comments24209
Node: Shell Commands24976
Node: Reserved Words25915
Node: Simple Commands27058
Node: Pipelines27720
Node: Lists30976
Node: Compound Commands32925
Node: Looping Constructs33934
Node: Conditional Constructs36483
Node: Command Grouping51780
Node: Coprocesses53272
Node: GNU Parallel55958
Node: Shell Functions56876
Node: Shell Parameters65324
Node: Positional Parameters70225
Node: Special Parameters71315
Node: Shell Expansions74776
Node: Brace Expansion76965
Node: Tilde Expansion80301
Node: Shell Parameter Expansion83256
Node: Command Substitution104104
Node: Arithmetic Expansion107955
Node: Process Substitution109139
Node: Word Splitting110247
Node: Filename Expansion112691
Node: Pattern Matching115915
Node: Quote Removal121681
Node: Redirections121985
Node: Executing Commands132241
Node: Simple Command Expansion132908
Node: Command Search and Execution135016
Node: Command Execution Environment137460
Node: Environment140986
Node: Exit Status142889
Node: Signals144948
Node: Shell Scripts149896
Node: Shell Builtin Commands153200
Node: Bourne Shell Builtins155541
Node: Bash Builtins182260
Node: Modifying Shell Behavior219995
Node: The Set Builtin220337
Node: The Shopt Builtin232331
Node: Special Builtins249384
Node: Shell Variables250373
Node: Bourne Shell Variables250807
Node: Bash Variables253315
Node: Bash Features292599
Node: Invoking Bash293613
Node: Bash Startup Files300843
Node: Interactive Shells306165
Node: What is an Interactive Shell?306573
Node: Is this Shell Interactive?307235
Node: Interactive Shell Behavior308059
Node: Bash Conditional Expressions311820
Node: Shell Arithmetic317237
Node: Aliases320564
Node: Arrays323698
Node: The Directory Stack331400
Node: Directory Stack Builtins332197
Node: Controlling the Prompt336642
Node: The Restricted Shell339526
Node: Bash POSIX Mode342619
Node: Shell Compatibility Mode362435
Node: Job Control371442
Node: Job Control Basics371899
Node: Job Control Builtins378267
Node: Job Control Variables385055
Node: Command Line Editing386286
Node: Introduction and Notation387989
Node: Readline Interaction390341
Node: Readline Bare Essentials391529
Node: Readline Movement Commands393337
Node: Readline Killing Commands394333
Node: Readline Arguments396356
Node: Searching397446
Node: Readline Init File399689
Node: Readline Init File Syntax400992
Node: Conditional Init Constructs427943
Node: Sample Init File432328
Node: Bindable Readline Commands435448
Node: Commands For Moving436986
Node: Commands For History439450
Node: Commands For Text444841
Node: Commands For Killing448966
Node: Numeric Arguments451754
Node: Commands For Completion452906
Node: Keyboard Macros458602
Node: Miscellaneous Commands459303
Node: Readline vi Mode466846
Node: Programmable Completion467823
Node: Programmable Completion Builtins477559
Node: A Programmable Completion Example489296
Node: Using History Interactively494641
Node: Bash History Facilities495322
Node: Bash History Builtins499057
Node: History Interaction506652
Node: Event Designators511602
Node: Word Designators513180
Node: Modifiers515572
Node: Installing Bash517509
Node: Basic Installation518625
Node: Compilers and Options522501
Node: Compiling For Multiple Architectures523251
Node: Installation Names525004
Node: Specifying the System Type527238
Node: Sharing Defaults527984
Node: Operation Controls528698
Node: Optional Features529717
Node: Reporting Bugs542440
Node: Major Differences From The Bourne Shell543797
Node: GNU Free Documentation License565224
Node: Indexes590401
Node: Builtin Index590852
Node: Reserved Word Index597950
Node: Variable Index600395
Node: Function Index617808
Node: Concept Index631941
Node: Word Splitting110306
Node: Filename Expansion112750
Node: Pattern Matching115974
Node: Quote Removal121740
Node: Redirections122044
Node: Executing Commands132313
Node: Simple Command Expansion132980
Node: Command Search and Execution135088
Node: Command Execution Environment137532
Node: Environment141058
Node: Exit Status142961
Node: Signals145020
Node: Shell Scripts149968
Node: Shell Builtin Commands153272
Node: Bourne Shell Builtins155613
Node: Bash Builtins182332
Node: Modifying Shell Behavior220067
Node: The Set Builtin220409
Node: The Shopt Builtin232403
Node: Special Builtins249456
Node: Shell Variables250445
Node: Bourne Shell Variables250879
Node: Bash Variables253387
Node: Bash Features292671
Node: Invoking Bash293685
Node: Bash Startup Files300915
Node: Interactive Shells306237
Node: What is an Interactive Shell?306645
Node: Is this Shell Interactive?307307
Node: Interactive Shell Behavior308131
Node: Bash Conditional Expressions311892
Node: Shell Arithmetic317309
Node: Aliases320636
Node: Arrays323770
Node: The Directory Stack331472
Node: Directory Stack Builtins332269
Node: Controlling the Prompt336714
Node: The Restricted Shell339795
Node: Bash POSIX Mode342888
Node: Shell Compatibility Mode362704
Node: Job Control371711
Node: Job Control Basics372168
Node: Job Control Builtins378536
Node: Job Control Variables385324
Node: Command Line Editing386555
Node: Introduction and Notation388258
Node: Readline Interaction390610
Node: Readline Bare Essentials391798
Node: Readline Movement Commands393606
Node: Readline Killing Commands394602
Node: Readline Arguments396625
Node: Searching397715
Node: Readline Init File399958
Node: Readline Init File Syntax401261
Node: Conditional Init Constructs428212
Node: Sample Init File432597
Node: Bindable Readline Commands435717
Node: Commands For Moving437255
Node: Commands For History439719
Node: Commands For Text445110
Node: Commands For Killing449235
Node: Numeric Arguments452023
Node: Commands For Completion453175
Node: Keyboard Macros458871
Node: Miscellaneous Commands459572
Node: Readline vi Mode467115
Node: Programmable Completion468092
Node: Programmable Completion Builtins477828
Node: A Programmable Completion Example489565
Node: Using History Interactively494910
Node: Bash History Facilities495591
Node: Bash History Builtins499326
Node: History Interaction506921
Node: Event Designators511871
Node: Word Designators513449
Node: Modifiers515841
Node: Installing Bash517778
Node: Basic Installation518894
Node: Compilers and Options522770
Node: Compiling For Multiple Architectures523520
Node: Installation Names525273
Node: Specifying the System Type527507
Node: Sharing Defaults528253
Node: Operation Controls528967
Node: Optional Features529986
Node: Reporting Bugs542709
Node: Major Differences From The Bourne Shell544066
Node: GNU Free Documentation License565493
Node: Indexes590670
Node: Builtin Index591121
Node: Reserved Word Index598219
Node: Variable Index600664
Node: Function Index618077
Node: Concept Index632210

End Tag Table
BIN
View File
Binary file not shown.
+152 -147
View File
@@ -1,10 +1,10 @@
This is bashref.info, produced by makeinfo version 7.2 from
This is bashref.info, produced by makeinfo version 7.3 from
bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 29 April 2026).
Bash shell (version 5.3, 18 May 2026).
This is Edition 5.3, last updated 29 April 2026, of The GNU Bash
This is Edition 5.3, last updated 18 May 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Copyright © 1988-2026 Free Software Foundation, Inc.
@@ -27,10 +27,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 29 April 2026). The Bash home page is
Bash shell (version 5.3, 18 May 2026). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 29 April 2026, of The GNU Bash
This is Edition 5.3, last updated 18 May 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -2466,8 +2466,8 @@ expressions that evaluate to 0. Arithmetic expansions may be nested.
The evaluation is performed according to the rules listed below
(*note Shell Arithmetic::). If the expression is invalid, Bash prints a
message indicating failure to the standard error, does not perform the
substitution, and does not execute the command associated with the
expansion.
substitution, and does not continue to execute the command in which the
error occurs.

File: bashref.info, Node: Process Substitution, Next: Word Splitting, Prev: Arithmetic Expansion, Up: Shell Expansions
@@ -2480,8 +2480,9 @@ to using a filename. It takes the form of
<(LIST)
or
>(LIST)
The process LIST is run asynchronously, and its input or output appears
as a filename. This filename is passed as an argument to the current
The process LIST, as long as it is not a null command without
redirections, is run asynchronously, and its input or output appears as
a filename. This filename is passed as an argument to the current
command as the result of the expansion.
If the >(LIST) form is used, writing to the file provides input for
@@ -2912,9 +2913,9 @@ If WORD is unquoted, DELIMITER is WORD itself, and the here-document
text is treated similarly to a double-quoted string: all lines of the
here-document are subjected to parameter expansion, command
substitution, and arithmetic expansion, the character sequence
\newline is treated literally, and \ must be used to quote the
characters \, $, and `; however, double quote characters have no
special meaning.
\newline is treated as a line continuation, and \ must be used to
quote the characters \, $, and `; however, double quote characters
have no special meaning.
If the redirection operator is <<-, the shell strips leading tab
characters from input lines and the line containing DELIMITER. This
@@ -7622,9 +7623,13 @@ can appear in the prompt variables PS0, PS1, PS2, and PS4
A backslash.
\[
Begin a sequence of non-printing characters. This could be used to
embed a terminal control sequence into the prompt.
embed a terminal control sequence into the prompt. This escape is
only useful when the prompt will be supplied to Readline, so it
shouldn't be used in PS0 or PS4, or when line editing is not
enabled.
\]
End a sequence of non-printing characters.
End a sequence of non-printing characters begun with \[
The command number and the history number are usually different: the
history number of a command is its position in the history list, which
@@ -13680,7 +13685,7 @@ D.5 Concept Index
* history list: Bash History Facilities.
(line 6)
* History, how to use: A Programmable Completion Example.
(line 113)
(line 112)
* identifier: Definitions. (line 55)
* initialization file, readline: Readline Init File. (line 6)
* installation: Basic Installation. (line 6)
@@ -13730,7 +13735,7 @@ D.5 Concept Index
* quoting: Quoting. (line 6)
* quoting, ANSI: ANSI-C Quoting. (line 6)
* Readline, how to use: Job Control Variables.
(line 23)
(line 22)
* redirection: Redirections. (line 6)
* reserved word: Definitions. (line 74)
* reserved words: Reserved Words. (line 6)
@@ -13764,138 +13769,138 @@ D.5 Concept Index

Tag Table:
Node: Top898
Node: Introduction2836
Node: What is Bash?3052
Node: What is a shell?4188
Node: Definitions6801
Node: Basic Shell Features10131
Node: Shell Syntax11358
Node: Shell Operation12388
Node: Quoting13682
Node: Escape Character15023
Node: Single Quotes15561
Node: Double Quotes15913
Node: ANSI-C Quoting17261
Node: Locale Translation18658
Node: Creating Internationalized Scripts20064
Node: Comments24265
Node: Shell Commands25035
Node: Reserved Words25977
Node: Simple Commands27123
Node: Pipelines27788
Node: Lists31047
Node: Compound Commands32999
Node: Looping Constructs34011
Node: Conditional Constructs36563
Node: Command Grouping51863
Node: Coprocesses53358
Node: GNU Parallel56047
Node: Shell Functions56968
Node: Shell Parameters65419
Node: Positional Parameters70323
Node: Special Parameters71416
Node: Shell Expansions74880
Node: Brace Expansion77072
Node: Tilde Expansion80411
Node: Shell Parameter Expansion83369
Node: Command Substitution104220
Node: Arithmetic Expansion108074
Node: Top894
Node: Introduction2828
Node: What is Bash?3044
Node: What is a shell?4180
Node: Definitions6793
Node: Basic Shell Features10123
Node: Shell Syntax11350
Node: Shell Operation12380
Node: Quoting13674
Node: Escape Character15015
Node: Single Quotes15553
Node: Double Quotes15905
Node: ANSI-C Quoting17253
Node: Locale Translation18650
Node: Creating Internationalized Scripts20056
Node: Comments24257
Node: Shell Commands25027
Node: Reserved Words25969
Node: Simple Commands27115
Node: Pipelines27780
Node: Lists31039
Node: Compound Commands32991
Node: Looping Constructs34003
Node: Conditional Constructs36555
Node: Command Grouping51855
Node: Coprocesses53350
Node: GNU Parallel56039
Node: Shell Functions56960
Node: Shell Parameters65411
Node: Positional Parameters70315
Node: Special Parameters71408
Node: Shell Expansions74872
Node: Brace Expansion77064
Node: Tilde Expansion80403
Node: Shell Parameter Expansion83361
Node: Command Substitution104212
Node: Arithmetic Expansion108066
Node: Process Substitution109253
Node: Word Splitting110364
Node: Filename Expansion112811
Node: Pattern Matching116038
Node: Quote Removal121807
Node: Redirections122114
Node: Executing Commands132373
Node: Simple Command Expansion133043
Node: Command Search and Execution135154
Node: Command Execution Environment137601
Node: Environment141130
Node: Exit Status143036
Node: Signals145098
Node: Shell Scripts150049
Node: Shell Builtin Commands153356
Node: Bourne Shell Builtins155700
Node: Bash Builtins182422
Node: Modifying Shell Behavior220160
Node: The Set Builtin220505
Node: The Shopt Builtin232502
Node: Special Builtins249558
Node: Shell Variables250550
Node: Bourne Shell Variables250987
Node: Bash Variables253498
Node: Bash Features292785
Node: Invoking Bash293802
Node: Bash Startup Files301035
Node: Interactive Shells306360
Node: What is an Interactive Shell?306771
Node: Is this Shell Interactive?307436
Node: Interactive Shell Behavior308263
Node: Bash Conditional Expressions312027
Node: Shell Arithmetic317447
Node: Aliases320777
Node: Arrays323914
Node: The Directory Stack331619
Node: Directory Stack Builtins332419
Node: Controlling the Prompt336867
Node: The Restricted Shell339754
Node: Bash POSIX Mode342850
Node: Shell Compatibility Mode362669
Node: Job Control371679
Node: Job Control Basics372139
Node: Job Control Builtins378510
Node: Job Control Variables385301
Node: Command Line Editing386535
Node: Introduction and Notation388241
Node: Readline Interaction390596
Node: Readline Bare Essentials391787
Node: Readline Movement Commands393598
Node: Readline Killing Commands394597
Node: Readline Arguments396623
Node: Searching397716
Node: Readline Init File399962
Node: Readline Init File Syntax401268
Node: Conditional Init Constructs428222
Node: Sample Init File432610
Node: Bindable Readline Commands435733
Node: Commands For Moving437274
Node: Commands For History439741
Node: Commands For Text445135
Node: Commands For Killing449263
Node: Numeric Arguments452054
Node: Commands For Completion453209
Node: Keyboard Macros458908
Node: Miscellaneous Commands459612
Node: Readline vi Mode467158
Node: Programmable Completion468138
Node: Programmable Completion Builtins477877
Node: A Programmable Completion Example489617
Node: Using History Interactively494965
Node: Bash History Facilities495649
Node: Bash History Builtins499387
Node: History Interaction506985
Node: Event Designators511938
Node: Word Designators513519
Node: Modifiers515914
Node: Installing Bash517854
Node: Basic Installation518973
Node: Compilers and Options522852
Node: Compiling For Multiple Architectures523605
Node: Installation Names525361
Node: Specifying the System Type527598
Node: Sharing Defaults528347
Node: Operation Controls529064
Node: Optional Features530086
Node: Reporting Bugs542812
Node: Major Differences From The Bourne Shell544172
Node: GNU Free Documentation License565602
Node: Indexes590782
Node: Builtin Index591236
Node: Reserved Word Index598337
Node: Variable Index600785
Node: Function Index618201
Node: Concept Index632337
Node: Word Splitting110423
Node: Filename Expansion112870
Node: Pattern Matching116097
Node: Quote Removal121866
Node: Redirections122173
Node: Executing Commands132445
Node: Simple Command Expansion133115
Node: Command Search and Execution135226
Node: Command Execution Environment137673
Node: Environment141202
Node: Exit Status143108
Node: Signals145170
Node: Shell Scripts150121
Node: Shell Builtin Commands153428
Node: Bourne Shell Builtins155772
Node: Bash Builtins182494
Node: Modifying Shell Behavior220232
Node: The Set Builtin220577
Node: The Shopt Builtin232574
Node: Special Builtins249630
Node: Shell Variables250622
Node: Bourne Shell Variables251059
Node: Bash Variables253570
Node: Bash Features292857
Node: Invoking Bash293874
Node: Bash Startup Files301107
Node: Interactive Shells306432
Node: What is an Interactive Shell?306843
Node: Is this Shell Interactive?307508
Node: Interactive Shell Behavior308335
Node: Bash Conditional Expressions312099
Node: Shell Arithmetic317519
Node: Aliases320849
Node: Arrays323986
Node: The Directory Stack331691
Node: Directory Stack Builtins332491
Node: Controlling the Prompt336939
Node: The Restricted Shell340023
Node: Bash POSIX Mode343119
Node: Shell Compatibility Mode362938
Node: Job Control371948
Node: Job Control Basics372408
Node: Job Control Builtins378779
Node: Job Control Variables385570
Node: Command Line Editing386804
Node: Introduction and Notation388510
Node: Readline Interaction390865
Node: Readline Bare Essentials392056
Node: Readline Movement Commands393867
Node: Readline Killing Commands394866
Node: Readline Arguments396892
Node: Searching397985
Node: Readline Init File400231
Node: Readline Init File Syntax401537
Node: Conditional Init Constructs428491
Node: Sample Init File432879
Node: Bindable Readline Commands436002
Node: Commands For Moving437543
Node: Commands For History440010
Node: Commands For Text445404
Node: Commands For Killing449532
Node: Numeric Arguments452323
Node: Commands For Completion453478
Node: Keyboard Macros459177
Node: Miscellaneous Commands459881
Node: Readline vi Mode467427
Node: Programmable Completion468407
Node: Programmable Completion Builtins478146
Node: A Programmable Completion Example489886
Node: Using History Interactively495234
Node: Bash History Facilities495918
Node: Bash History Builtins499656
Node: History Interaction507254
Node: Event Designators512207
Node: Word Designators513788
Node: Modifiers516183
Node: Installing Bash518123
Node: Basic Installation519242
Node: Compilers and Options523121
Node: Compiling For Multiple Architectures523874
Node: Installation Names525630
Node: Specifying the System Type527867
Node: Sharing Defaults528616
Node: Operation Controls529333
Node: Optional Features530355
Node: Reporting Bugs543081
Node: Major Differences From The Bourne Shell544441
Node: GNU Free Documentation License565871
Node: Indexes591051
Node: Builtin Index591505
Node: Reserved Word Index598606
Node: Variable Index601054
Node: Function Index618470
Node: Concept Index632606

End Tag Table
+2 -1
View File
@@ -9158,7 +9158,8 @@ Begin a sequence of non-printing characters.
This could be used to
embed a terminal control sequence into the prompt.
This escape is only useful when the prompt will be supplied to
Readline, so it shouldn't be used in @env{PS0} or @env{PS4}.
Readline, so it shouldn't be used in @env{PS0} or @env{PS4},
or when line editing is not enabled.
@item \]
End a sequence of non-printing characters begun with @samp{\[}
+9 -5
View File
@@ -3234,6 +3234,15 @@ string_list_pos_params (int pchar, WORD_LIST *list, int quoted, int pflags)
separator. */
ret = string_list_dollar_star (list, quoted, 0);
}
else if (pchar == '@' && (pflags & PF_ASSIGNRHS))
/* XXX - param_expand uses quoted|Q_DOUBLE_QUOTES for this case, but
that quotes the escapes. We could use string_list_internal with " "
as the second argument. */
/* This makes $@ on the rhs of an assignment statement behave the
same quoted as unquoted (each argument separated by a space instead
of the first character of IFS), whether or not the expansion is
standalone ($@) or part of a different word expansion. */
ret = string_list_dollar_at (list, quoted, pflags); /* Posix interp 888 */
else if (pchar == '@' && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)))
/* We use string_list_dollar_at, but only if the string is quoted, since
that quotes the escapes if it's not, which we don't want. We could
@@ -3245,11 +3254,6 @@ string_list_pos_params (int pchar, WORD_LIST *list, int quoted, int pflags)
ret = string_list_dollar_at (list, quoted, 0);
else if (pchar == '@' && quoted == 0 && ifs_is_null) /* XXX */
ret = string_list_dollar_at (list, quoted, 0); /* Posix interp 888 */
else if (pchar == '@' && quoted == 0 && (pflags & PF_ASSIGNRHS))
/* XXX - param_expand uses quoted|Q_DOUBLE_QUOTES for this case, but
that quotes the escapes. We could use string_list_internal with " "
as the second argument. */
ret = string_list_dollar_at (list, quoted, pflags); /* Posix interp 888 */
else if (pchar == '@' && quoted == 0 && (pflags & PF_ASSIGNRHS) == 0 &&
ifs_is_set && ifs_is_null == 0 &&
#if defined (HANDLE_MULTIBYTE)
+1 -1
View File
@@ -92,5 +92,5 @@ ok1
./arith-for.tests: line 137: ((: 7=4 : attempted assignment to non-variable (error token is "=4 ")
./arith-for.tests: line 139: ((: j=: arithmetic syntax error: operand expected (error token is "=")
X
./arith-for.tests: line 141: break: only meaningful in a `for', `while', or `until' loop
./arith-for.tests: line 141: break: only meaningful in a `for', `while', `until', or `select' loop
Y
+2 -2
View File
@@ -33,8 +33,8 @@ declare: usage: declare [-aAfFgiIlnrtux] [name[=value] ...] or declare -p [-aAfF
./errors.tests: line 115: exec: -i: invalid option
exec: usage: exec [-cl] [-a name] [command [argument ...]] [redirection ...]
./errors.tests: line 122: export: XPATH: not a function
./errors.tests: line 125: break: only meaningful in a `for', `while', or `until' loop
./errors.tests: line 126: continue: only meaningful in a `for', `while', or `until' loop
./errors.tests: line 125: break: only meaningful in a `for', `while', `until', or `select' loop
./errors.tests: line 126: continue: only meaningful in a `for', `while', `until', or `select' loop
./errors.tests: line 129: shift: label: numeric argument required
./errors.tests: line 134: shift: too many arguments
./errors.tests: line 140: let: expression expected
+31 -7
View File
@@ -459,18 +459,42 @@ Q= <a b c> <a:b:c>
Q+ <a b c> <a:b:c>
+Q+ <a b c> <a:b:c>
!Q: <a b c> <a:b:c>
Q: <a:b:c> <a:b:c>
Q: <a b c> <a:b:c>
!Q# <a b c> <a:b:c>
Q# <a:b:c> <a:b:c>
Q# <a b c> <a:b:c>
!Q% <a b c> <a:b:c>
Q% <a:b:c> <a:b:c>
Q% <a b c> <a:b:c>
!Q/ <x x x> <x:x:x>
Q/ <x:x:x> <x:x:x>
Q/ <x x x> <x:x:x>
!Q^ <A B C> <A:B:C>
Q^ <A:B:C> <A:B:C>
Q^ <A B C> <A:B:C>
!Q, <a b c> <a:b:c>
Q, <a:b:c> <a:b:c>
Q, <a b c> <a:b:c>
!Q@Q <'a' 'b' 'c'> <'a':'b':'c'>
Q@Q <'a':'b':'c'> <'a':'b':'c'>
Q@Q <'a' 'b' 'c'> <'a':'b':'c'>
!Q@A <set -- 'a':'b':'c'> <set -- 'a':'b':'c'>
Q@A <set -- 'a':'b':'c'> <set -- 'a':'b':'c'>
declare -- b="0 1"
declare -- b="0 1"
declare -- b="0 1"
declare -- b="0 1"
declare -- b="0 1"
declare -- b="0 1"
declare -- b="0:1"
declare -- b="0:1"
declare -- b="0 1"
declare -- b="0 1"
declare -- b="01"
declare -- b="01"
declare -- b="a b"
declare -- b="a b"
declare -- b="a b"
declare -- b="a b"
declare -- b="a b"
declare -- b="a b"
declare -- b="a:b"
declare -- b="a:b"
declare -- b="a b"
declare -- b="a b"
declare -- b="ab"
declare -- b="ab"
+31
View File
@@ -67,3 +67,34 @@ IFS=:; o="${@@Q}" s="${*@Q}"; printf 'Q@Q <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
# positional parameter transformation -- assignment
IFS=:; o=${@@A} s=${*@A}; printf '!Q@A <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
IFS=:; o="${@@A}" s="${*@A}"; printf 'Q@A <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
# direct and indirect (prefix) array expansions
IFS=' ' a=(a b) b=${!a[@]} ; declare -p b
IFS=' ' a=(a b) b="${!a[@]}"; declare -p b
IFS=' ' a=(a b) b=${!a[*]} ; declare -p b
IFS=' ' a=(a b) b="${!a[*]}"; declare -p b
IFS=':' a=(a b) b=${!a[@]} ; declare -p b
IFS=':' a=(a b) b="${!a[@]}"; declare -p b
IFS=':' a=(a b) b=${!a[*]} ; declare -p b
IFS=':' a=(a b) b="${!a[*]}"; declare -p b
IFS='' a=(a b) b=${!a[@]} ; declare -p b
IFS='' a=(a b) b="${!a[@]}"; declare -p b
IFS='' a=(a b) b=${!a[*]} ; declare -p b
IFS='' a=(a b) b="${!a[*]}"; declare -p b
IFS=' ' a=(a b) b=${a[@]} ; declare -p b
IFS=' ' a=(a b) b="${a[@]}"; declare -p b
IFS=' ' a=(a b) b=${a[*]} ; declare -p b
IFS=' ' a=(a b) b="${a[*]}"; declare -p b
IFS=':' a=(a b) b=${a[@]} ; declare -p b
IFS=':' a=(a b) b="${a[@]}"; declare -p b
IFS=':' a=(a b) b=${a[*]} ; declare -p b
IFS=':' a=(a b) b="${a[*]}"; declare -p b
IFS='' a=(a b) b=${a[@]} ; declare -p b
IFS='' a=(a b) b="${a[@]}"; declare -p b
IFS='' a=(a b) b=${a[*]} ; declare -p b
IFS='' a=(a b) b="${a[*]}"; declare -p b
+1 -2
View File
@@ -287,7 +287,6 @@ static SHELL_VAR *bind_variable_internal (const char *, const char *, HASH_TABLE
static void init_variable (SHELL_VAR *);
static void init_shell_variable (SHELL_VAR *);
static void dispose_variable_value (SHELL_VAR *);
static void free_variable_hash_data (PTR_T);
static VARLIST *vlist_alloc (size_t);
@@ -3744,7 +3743,7 @@ copy_variable (SHELL_VAR *var)
/* **************************************************************** */
/* Dispose of the information attached to VAR. */
static void
void
dispose_variable_value (SHELL_VAR *var)
{
if (nofree_p (var))
+2 -1
View File
@@ -1,6 +1,6 @@
/* variables.h -- data structures for shell variables. */
/* Copyright (C) 1987-2025 Free Software Foundation, Inc.
/* Copyright (C) 1987-2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -388,6 +388,7 @@ extern void push_source (ARRAY *, char *);
extern void adjust_shell_level (int);
extern void non_unsettable (char *);
extern void dispose_variable_value (SHELL_VAR *);
extern void dispose_variable (SHELL_VAR *);
extern void dispose_used_env_vars (void);
extern void dispose_function_env (void);