From: Chet Ramey Date: Mon, 6 Dec 2021 14:17:41 +0000 (-0500) Subject: portability and compatibility fixes X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=71a11dbeb478fb637ea451f2f37c73d7539cc1f5;p=thirdparty%2Fbash.git portability and compatibility fixes --- diff --git a/COMPAT b/COMPAT index 019805b4c..aa25f19d8 100644 --- a/COMPAT +++ b/COMPAT @@ -552,6 +552,27 @@ compat50 (set using BASH_COMPAT) suppresses that message if -l is supplied compat51 (set using BASH_COMPAT) + - The `unset' builtin will unset the array a given an argument like + `a[@]'. Bash-5.2 will unset an element with key `@' (associative + arrays) or remove all the elements without unsetting the array + (indexed arrays) + - arithmetic commands ( ((...)) ) and the expressions in an arithmetic + for statement can be expanded more than once + - expressions used as arguments to arithmetic operators in the [[ + conditional command can be expanded more than once + - the expressions in substring parameter brace expansion can be + expanded more than once + - the expressions in the $(( ... )) word expansion can be expanded + more than once + - arithmetic expressions used as indexed array subscripts can be + expanded more than once; + - `test -v', when given an argument of A[@], where A is an existing + associative array, will return true if the array has any set + elements. Bash-5.2 will look for a key named `@'; + - the ${param[:]=value} word expansion will return VALUE, before any + variable-specific transformations have been performed (e.g., + converting to lowercase). Bash-5.2 will return the final value + assigned to the variable, as POSIX specifies ------------------------------------------------------------------------------- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index cbe7d89df..39a2af970 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -2578,3 +2578,32 @@ subst.c doc/bashref.texi - --enable-translatable-strings: document new configuration option + + 12/2 + ---- +subst.c + - verify_substring_values: now that the default compatibility level is + 52, and the Q_ARITH code is enabled, make the EXP_EXPANDED flag for + evalexp() dependent on the compatibility level + - param_expand: arithmetic substitution: make EXP_EXPANDED flag + for evalexp() dependent on the compatibility level + - expand_word_internal: don't call expand_array_subscript if the + shell compatibility level is 51 or below (Q_ARITH) + +test.c + - test_unop: if the shell compatibility level is > 51, using [@] with + an existing associative array will report on a key of `@' + +arrayfunc.c + - array_expand_index: if the compatibility level is > 51, Q_ARITH is + used and we don't pass EXP_EXPANDED to evalexp() + +COMPAT,doc/bashref.texi + - shell compatibility mode: document effects of setting the + compatibility mode to 51 + + 12/3 + ---- +lib/malloc/malloc.c + - mremap: only use if MREMAP_MAYMOVE is defined, since we use the Linux + version of the function signature diff --git a/arrayfunc.c b/arrayfunc.c index 00576a9dc..816560524 100644 --- a/arrayfunc.c +++ b/arrayfunc.c @@ -1301,11 +1301,7 @@ array_expand_index (var, s, len, flags) #endif savecmd = this_command_name; this_command_name = (char *)NULL; -#if 0 /* TAG:bash-5.2 */ eflag = (shell_compatibility_level > 51) ? 0 : EXP_EXPANDED; -#else - eflag = 0; -#endif val = evalexp (t, eflag, &expok); /* XXX - was 0 but we expanded exp already */ this_command_name = savecmd; if (t != exp) diff --git a/builtins/common.c b/builtins/common.c index 91a62f5b8..563a06262 100644 --- a/builtins/common.c +++ b/builtins/common.c @@ -1088,7 +1088,7 @@ set_expand_once (nval, uwp) int oa; oa = assoc_expand_once; - if (shell_compatibility_level > 51) + if (shell_compatibility_level > 51) /* XXX - internal */ { if (uwp) unwind_protect_int (assoc_expand_once); diff --git a/builtins/shopt.def b/builtins/shopt.def index 9dba27e3b..1c7826011 100644 --- a/builtins/shopt.def +++ b/builtins/shopt.def @@ -918,7 +918,7 @@ set_assoc_expand (option_name, mode) char *option_name; int mode; { -#if 0 /* TAG: bash-5.2, fix shell_compatibility_level test */ +#if 0 /* leave this disabled */ if (shell_compatibility_level <= 51) #endif assoc_expand_once = expand_once_flag; diff --git a/compatibility-level b/compatibility-level new file mode 100644 index 000000000..8edd8d4d1 --- /dev/null +++ b/compatibility-level @@ -0,0 +1,27 @@ +o The `unset' builtin will unset the array a given an argument like `a[@]'. + Bash-5.2 will unset an element with key `@' (associative arrays) or remove + all the elements without unsetting the array (indexed arrays); + +o arithmetic commands ( ((...)) ) and the expressions in an arithmetic for + statement can be expanded more than once; + +o expressions used as arguments to arithmetic operators in the [[ conditional + command can be expanded more than once; + +o the expressions in substring parameter brace expansion can be + expanded more than once; + +o the expressions in the $(( ... )) word expansion can be expanded + more than once; + +o arithmetic expressions used as indexed array subscripts can be + expanded more than once; + +o `test -v', when given an argument of A[@], where A is an existing + associative array, will return true if the array has any set elements. + Bash-5.2 will look for a key named `@'; + +o the ${param[:]=value} word expansion will return VALUE, before any + variable-specific transformations have been performed (e.g., converting + to lowercase). Bash-5.2 will return the final value assigned to the + variable. diff --git a/doc/bash.info b/doc/bash.info index 653da0add..8dc44b5cf 100644 --- a/doc/bash.info +++ b/doc/bash.info @@ -1,9 +1,9 @@ This is bash.info, produced by makeinfo version 6.8 from bashref.texi. This text is a brief description of the features that are present in the -Bash shell (version 5.2, 22 November 2021). +Bash shell (version 5.2, 2 December 2021). - This is Edition 5.2, last updated 22 November 2021, of 'The GNU Bash + This is Edition 5.2, last updated 2 December 2021, of 'The GNU Bash Reference Manual', for 'Bash', Version 5.2. Copyright (C) 1988-2021 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.2, 22 November 2021). The Bash home page is +Bash shell (version 5.2, 2 December 2021). The Bash home page is . - This is Edition 5.2, last updated 22 November 2021, of 'The GNU Bash + This is Edition 5.2, last updated 2 December 2021, of 'The GNU Bash Reference Manual', for 'Bash', Version 5.2. Bash contains features that appear in other popular shells, and some @@ -7349,10 +7349,28 @@ required for bash-5.1 and later versions. suppresses that message when the '-l' option is supplied. 'compat51 (set using BASH_COMPAT)' - * The 'unset' builtin treats attempts to unset array subscripts - '@' and '*' differently depending on whether the array is - indexed or associative, and differently than in previous - versions. + * The 'unset' builtin will unset the array 'a' given an argument + like 'a[@]'. Bash-5.2 will unset an element with key '@' + (associative arrays) or remove all the elements without + unsetting the array (indexed arrays) + * arithmetic commands ( ((...)) ) and the expressions in an + arithmetic for statement can be expanded more than once + * expressions used as arguments to arithmetic operators in the + '[[' conditional command can be expanded more than once + * the expressions in substring parameter brace expansion can be + expanded more than once + * the expressions in the $(( ... )) word expansion can be + expanded more than once + * arithmetic expressions used as indexed array subscripts can be + expanded more than once + * 'test -v', when given an argument of 'A[@]', where A is an + existing associative array, will return true if the array has + any set elements. Bash-5.2 will look for and report on a key + named '@' + * the ${PARAMETER[:]=VALUE} word expansion will return VALUE, + before any variable-specific transformations have been + performed (e.g., converting to lowercase). Bash-5.2 will + return the final value assigned to the variable.  File: bash.info, Node: Job Control, Next: Command Line Editing, Prev: Bash Features, Up: Top @@ -10719,6 +10737,10 @@ does not provide the necessary support. '--enable-strict-posix-default' Make Bash POSIX-conformant by default (*note Bash POSIX Mode::). +'--enable-translatable-strings' + Enable support for '$"STRING"' translatable strings (*note Locale + Translation::). + '--enable-usg-echo-default' A synonym for '--enable-xpg-echo-default'. @@ -12392,138 +12414,138 @@ D.5 Concept Index  Tag Table: -Node: Top894 -Node: Introduction2811 -Node: What is Bash?3024 -Node: What is a shell?4135 -Node: Definitions6670 -Node: Basic Shell Features9618 -Node: Shell Syntax10834 -Node: Shell Operation11857 -Node: Quoting13147 -Node: Escape Character14448 -Node: Single Quotes14930 -Node: Double Quotes15275 -Node: ANSI-C Quoting16550 -Node: Locale Translation17857 -Node: Creating Internationalized Scripts19165 -Node: Comments23279 -Node: Shell Commands23894 -Node: Reserved Words24829 -Node: Simple Commands25582 -Node: Pipelines26233 -Node: Lists29189 -Node: Compound Commands30981 -Node: Looping Constructs31990 -Node: Conditional Constructs34482 -Node: Command Grouping48823 -Node: Coprocesses50298 -Node: GNU Parallel52958 -Node: Shell Functions53872 -Node: Shell Parameters61160 -Node: Positional Parameters65545 -Node: Special Parameters66444 -Node: Shell Expansions69655 -Node: Brace Expansion71779 -Node: Tilde Expansion74510 -Node: Shell Parameter Expansion77128 -Node: Command Substitution94991 -Node: Arithmetic Expansion96343 -Node: Process Substitution97308 -Node: Word Splitting98425 -Node: Filename Expansion100366 -Node: Pattern Matching102963 -Node: Quote Removal107568 -Node: Redirections107860 -Node: Executing Commands117517 -Node: Simple Command Expansion118184 -Node: Command Search and Execution120291 -Node: Command Execution Environment122666 -Node: Environment125698 -Node: Exit Status127358 -Node: Signals129139 -Node: Shell Scripts132585 -Node: Shell Builtin Commands135609 -Node: Bourne Shell Builtins137644 -Node: Bash Builtins159102 -Node: Modifying Shell Behavior189955 -Node: The Set Builtin190297 -Node: The Shopt Builtin200836 -Node: Special Builtins216547 -Node: Shell Variables217523 -Node: Bourne Shell Variables217957 -Node: Bash Variables220058 -Node: Bash Features252870 -Node: Invoking Bash253880 -Node: Bash Startup Files259890 -Node: Interactive Shells264990 -Node: What is an Interactive Shell?265397 -Node: Is this Shell Interactive?266043 -Node: Interactive Shell Behavior266855 -Node: Bash Conditional Expressions270481 -Node: Shell Arithmetic275120 -Node: Aliases278061 -Node: Arrays280671 -Node: The Directory Stack286915 -Node: Directory Stack Builtins287696 -Node: Controlling the Prompt291953 -Node: The Restricted Shell294915 -Node: Bash POSIX Mode297522 -Node: Shell Compatibility Mode308792 -Node: Job Control315708 -Node: Job Control Basics316165 -Node: Job Control Builtins321164 -Node: Job Control Variables326561 -Node: Command Line Editing327714 -Node: Introduction and Notation329382 -Node: Readline Interaction331002 -Node: Readline Bare Essentials332190 -Node: Readline Movement Commands333970 -Node: Readline Killing Commands334927 -Node: Readline Arguments336842 -Node: Searching337883 -Node: Readline Init File340066 -Node: Readline Init File Syntax341324 -Node: Conditional Init Constructs362809 -Node: Sample Init File367002 -Node: Bindable Readline Commands370123 -Node: Commands For Moving371324 -Node: Commands For History373372 -Node: Commands For Text378363 -Node: Commands For Killing382009 -Node: Numeric Arguments385039 -Node: Commands For Completion386175 -Node: Keyboard Macros390363 -Node: Miscellaneous Commands391047 -Node: Readline vi Mode396983 -Node: Programmable Completion397887 -Node: Programmable Completion Builtins405664 -Node: A Programmable Completion Example416356 -Node: Using History Interactively421600 -Node: Bash History Facilities422281 -Node: Bash History Builtins425283 -Node: History Interaction430288 -Node: Event Designators433905 -Node: Word Designators435256 -Node: Modifiers437013 -Node: Installing Bash438821 -Node: Basic Installation439955 -Node: Compilers and Options443674 -Node: Compiling For Multiple Architectures444412 -Node: Installation Names446102 -Node: Specifying the System Type448208 -Node: Sharing Defaults448921 -Node: Operation Controls449591 -Node: Optional Features450546 -Node: Reporting Bugs461636 -Node: Major Differences From The Bourne Shell462908 -Node: GNU Free Documentation License479755 -Node: Indexes504929 -Node: Builtin Index505380 -Node: Reserved Word Index512204 -Node: Variable Index514649 -Node: Function Index531138 -Node: Concept Index544919 +Node: Top892 +Node: Introduction2807 +Node: What is Bash?3020 +Node: What is a shell?4131 +Node: Definitions6666 +Node: Basic Shell Features9614 +Node: Shell Syntax10830 +Node: Shell Operation11853 +Node: Quoting13143 +Node: Escape Character14444 +Node: Single Quotes14926 +Node: Double Quotes15271 +Node: ANSI-C Quoting16546 +Node: Locale Translation17853 +Node: Creating Internationalized Scripts19161 +Node: Comments23275 +Node: Shell Commands23890 +Node: Reserved Words24825 +Node: Simple Commands25578 +Node: Pipelines26229 +Node: Lists29185 +Node: Compound Commands30977 +Node: Looping Constructs31986 +Node: Conditional Constructs34478 +Node: Command Grouping48819 +Node: Coprocesses50294 +Node: GNU Parallel52954 +Node: Shell Functions53868 +Node: Shell Parameters61156 +Node: Positional Parameters65541 +Node: Special Parameters66440 +Node: Shell Expansions69651 +Node: Brace Expansion71775 +Node: Tilde Expansion74506 +Node: Shell Parameter Expansion77124 +Node: Command Substitution94987 +Node: Arithmetic Expansion96339 +Node: Process Substitution97304 +Node: Word Splitting98421 +Node: Filename Expansion100362 +Node: Pattern Matching102959 +Node: Quote Removal107564 +Node: Redirections107856 +Node: Executing Commands117513 +Node: Simple Command Expansion118180 +Node: Command Search and Execution120287 +Node: Command Execution Environment122662 +Node: Environment125694 +Node: Exit Status127354 +Node: Signals129135 +Node: Shell Scripts132581 +Node: Shell Builtin Commands135605 +Node: Bourne Shell Builtins137640 +Node: Bash Builtins159098 +Node: Modifying Shell Behavior189951 +Node: The Set Builtin190293 +Node: The Shopt Builtin200832 +Node: Special Builtins216543 +Node: Shell Variables217519 +Node: Bourne Shell Variables217953 +Node: Bash Variables220054 +Node: Bash Features252866 +Node: Invoking Bash253876 +Node: Bash Startup Files259886 +Node: Interactive Shells264986 +Node: What is an Interactive Shell?265393 +Node: Is this Shell Interactive?266039 +Node: Interactive Shell Behavior266851 +Node: Bash Conditional Expressions270477 +Node: Shell Arithmetic275116 +Node: Aliases278057 +Node: Arrays280667 +Node: The Directory Stack286911 +Node: Directory Stack Builtins287692 +Node: Controlling the Prompt291949 +Node: The Restricted Shell294911 +Node: Bash POSIX Mode297518 +Node: Shell Compatibility Mode308788 +Node: Job Control316814 +Node: Job Control Basics317271 +Node: Job Control Builtins322270 +Node: Job Control Variables327667 +Node: Command Line Editing328820 +Node: Introduction and Notation330488 +Node: Readline Interaction332108 +Node: Readline Bare Essentials333296 +Node: Readline Movement Commands335076 +Node: Readline Killing Commands336033 +Node: Readline Arguments337948 +Node: Searching338989 +Node: Readline Init File341172 +Node: Readline Init File Syntax342430 +Node: Conditional Init Constructs363915 +Node: Sample Init File368108 +Node: Bindable Readline Commands371229 +Node: Commands For Moving372430 +Node: Commands For History374478 +Node: Commands For Text379469 +Node: Commands For Killing383115 +Node: Numeric Arguments386145 +Node: Commands For Completion387281 +Node: Keyboard Macros391469 +Node: Miscellaneous Commands392153 +Node: Readline vi Mode398089 +Node: Programmable Completion398993 +Node: Programmable Completion Builtins406770 +Node: A Programmable Completion Example417462 +Node: Using History Interactively422706 +Node: Bash History Facilities423387 +Node: Bash History Builtins426389 +Node: History Interaction431394 +Node: Event Designators435011 +Node: Word Designators436362 +Node: Modifiers438119 +Node: Installing Bash439927 +Node: Basic Installation441061 +Node: Compilers and Options444780 +Node: Compiling For Multiple Architectures445518 +Node: Installation Names447208 +Node: Specifying the System Type449314 +Node: Sharing Defaults450027 +Node: Operation Controls450697 +Node: Optional Features451652 +Node: Reporting Bugs462867 +Node: Major Differences From The Bourne Shell464139 +Node: GNU Free Documentation License480986 +Node: Indexes506160 +Node: Builtin Index506611 +Node: Reserved Word Index513435 +Node: Variable Index515880 +Node: Function Index532369 +Node: Concept Index546150  End Tag Table diff --git a/doc/bashref.info b/doc/bashref.info index 8523de790..1361ce7c6 100644 --- a/doc/bashref.info +++ b/doc/bashref.info @@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 6.8 from bashref.texi. This text is a brief description of the features that are present in the -Bash shell (version 5.2, 22 November 2021). +Bash shell (version 5.2, 2 December 2021). - This is Edition 5.2, last updated 22 November 2021, of 'The GNU Bash + This is Edition 5.2, last updated 2 December 2021, of 'The GNU Bash Reference Manual', for 'Bash', Version 5.2. Copyright (C) 1988-2021 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.2, 22 November 2021). The Bash home page is +Bash shell (version 5.2, 2 December 2021). The Bash home page is . - This is Edition 5.2, last updated 22 November 2021, of 'The GNU Bash + This is Edition 5.2, last updated 2 December 2021, of 'The GNU Bash Reference Manual', for 'Bash', Version 5.2. Bash contains features that appear in other popular shells, and some @@ -7350,10 +7350,28 @@ required for bash-5.1 and later versions. suppresses that message when the '-l' option is supplied. 'compat51 (set using BASH_COMPAT)' - * The 'unset' builtin treats attempts to unset array subscripts - '@' and '*' differently depending on whether the array is - indexed or associative, and differently than in previous - versions. + * The 'unset' builtin will unset the array 'a' given an argument + like 'a[@]'. Bash-5.2 will unset an element with key '@' + (associative arrays) or remove all the elements without + unsetting the array (indexed arrays) + * arithmetic commands ( ((...)) ) and the expressions in an + arithmetic for statement can be expanded more than once + * expressions used as arguments to arithmetic operators in the + '[[' conditional command can be expanded more than once + * the expressions in substring parameter brace expansion can be + expanded more than once + * the expressions in the $(( ... )) word expansion can be + expanded more than once + * arithmetic expressions used as indexed array subscripts can be + expanded more than once + * 'test -v', when given an argument of 'A[@]', where A is an + existing associative array, will return true if the array has + any set elements. Bash-5.2 will look for and report on a key + named '@' + * the ${PARAMETER[:]=VALUE} word expansion will return VALUE, + before any variable-specific transformations have been + performed (e.g., converting to lowercase). Bash-5.2 will + return the final value assigned to the variable.  File: bashref.info, Node: Job Control, Next: Command Line Editing, Prev: Bash Features, Up: Top @@ -12397,138 +12415,138 @@ D.5 Concept Index  Tag Table: -Node: Top897 -Node: Introduction2817 -Node: What is Bash?3033 -Node: What is a shell?4147 -Node: Definitions6685 -Node: Basic Shell Features9636 -Node: Shell Syntax10855 -Node: Shell Operation11881 -Node: Quoting13174 -Node: Escape Character14478 -Node: Single Quotes14963 -Node: Double Quotes15311 -Node: ANSI-C Quoting16589 -Node: Locale Translation17899 -Node: Creating Internationalized Scripts19210 -Node: Comments23327 -Node: Shell Commands23945 -Node: Reserved Words24883 -Node: Simple Commands25639 -Node: Pipelines26293 -Node: Lists29252 -Node: Compound Commands31047 -Node: Looping Constructs32059 -Node: Conditional Constructs34554 -Node: Command Grouping48898 -Node: Coprocesses50376 -Node: GNU Parallel53039 -Node: Shell Functions53956 -Node: Shell Parameters61247 -Node: Positional Parameters65635 -Node: Special Parameters66537 -Node: Shell Expansions69751 -Node: Brace Expansion71878 -Node: Tilde Expansion74612 -Node: Shell Parameter Expansion77233 -Node: Command Substitution95099 -Node: Arithmetic Expansion96454 -Node: Process Substitution97422 -Node: Word Splitting98542 -Node: Filename Expansion100486 -Node: Pattern Matching103086 -Node: Quote Removal107694 -Node: Redirections107989 -Node: Executing Commands117649 -Node: Simple Command Expansion118319 -Node: Command Search and Execution120429 -Node: Command Execution Environment122807 -Node: Environment125842 -Node: Exit Status127505 -Node: Signals129289 -Node: Shell Scripts132738 -Node: Shell Builtin Commands135765 -Node: Bourne Shell Builtins137803 -Node: Bash Builtins159264 -Node: Modifying Shell Behavior190120 -Node: The Set Builtin190465 -Node: The Shopt Builtin201007 -Node: Special Builtins216721 -Node: Shell Variables217700 -Node: Bourne Shell Variables218137 -Node: Bash Variables220241 -Node: Bash Features253056 -Node: Invoking Bash254069 -Node: Bash Startup Files260082 -Node: Interactive Shells265185 -Node: What is an Interactive Shell?265595 -Node: Is this Shell Interactive?266244 -Node: Interactive Shell Behavior267059 -Node: Bash Conditional Expressions270688 -Node: Shell Arithmetic275330 -Node: Aliases278274 -Node: Arrays280887 -Node: The Directory Stack287134 -Node: Directory Stack Builtins287918 -Node: Controlling the Prompt292178 -Node: The Restricted Shell295143 -Node: Bash POSIX Mode297753 -Node: Shell Compatibility Mode309026 -Node: Job Control315945 -Node: Job Control Basics316405 -Node: Job Control Builtins321407 -Node: Job Control Variables326807 -Node: Command Line Editing327963 -Node: Introduction and Notation329634 -Node: Readline Interaction331257 -Node: Readline Bare Essentials332448 -Node: Readline Movement Commands334231 -Node: Readline Killing Commands335191 -Node: Readline Arguments337109 -Node: Searching338153 -Node: Readline Init File340339 -Node: Readline Init File Syntax341600 -Node: Conditional Init Constructs363088 -Node: Sample Init File367284 -Node: Bindable Readline Commands370408 -Node: Commands For Moving371612 -Node: Commands For History373663 -Node: Commands For Text378657 -Node: Commands For Killing382306 -Node: Numeric Arguments385339 -Node: Commands For Completion386478 -Node: Keyboard Macros390669 -Node: Miscellaneous Commands391356 -Node: Readline vi Mode397295 -Node: Programmable Completion398202 -Node: Programmable Completion Builtins405982 -Node: A Programmable Completion Example416677 -Node: Using History Interactively421924 -Node: Bash History Facilities422608 -Node: Bash History Builtins425613 -Node: History Interaction430621 -Node: Event Designators434241 -Node: Word Designators435595 -Node: Modifiers437355 -Node: Installing Bash439166 -Node: Basic Installation440303 -Node: Compilers and Options444025 -Node: Compiling For Multiple Architectures444766 -Node: Installation Names446459 -Node: Specifying the System Type448568 -Node: Sharing Defaults449284 -Node: Operation Controls449957 -Node: Optional Features450915 -Node: Reporting Bugs462133 -Node: Major Differences From The Bourne Shell463408 -Node: GNU Free Documentation License480258 -Node: Indexes505435 -Node: Builtin Index505889 -Node: Reserved Word Index512716 -Node: Variable Index515164 -Node: Function Index531656 -Node: Concept Index545440 +Node: Top895 +Node: Introduction2813 +Node: What is Bash?3029 +Node: What is a shell?4143 +Node: Definitions6681 +Node: Basic Shell Features9632 +Node: Shell Syntax10851 +Node: Shell Operation11877 +Node: Quoting13170 +Node: Escape Character14474 +Node: Single Quotes14959 +Node: Double Quotes15307 +Node: ANSI-C Quoting16585 +Node: Locale Translation17895 +Node: Creating Internationalized Scripts19206 +Node: Comments23323 +Node: Shell Commands23941 +Node: Reserved Words24879 +Node: Simple Commands25635 +Node: Pipelines26289 +Node: Lists29248 +Node: Compound Commands31043 +Node: Looping Constructs32055 +Node: Conditional Constructs34550 +Node: Command Grouping48894 +Node: Coprocesses50372 +Node: GNU Parallel53035 +Node: Shell Functions53952 +Node: Shell Parameters61243 +Node: Positional Parameters65631 +Node: Special Parameters66533 +Node: Shell Expansions69747 +Node: Brace Expansion71874 +Node: Tilde Expansion74608 +Node: Shell Parameter Expansion77229 +Node: Command Substitution95095 +Node: Arithmetic Expansion96450 +Node: Process Substitution97418 +Node: Word Splitting98538 +Node: Filename Expansion100482 +Node: Pattern Matching103082 +Node: Quote Removal107690 +Node: Redirections107985 +Node: Executing Commands117645 +Node: Simple Command Expansion118315 +Node: Command Search and Execution120425 +Node: Command Execution Environment122803 +Node: Environment125838 +Node: Exit Status127501 +Node: Signals129285 +Node: Shell Scripts132734 +Node: Shell Builtin Commands135761 +Node: Bourne Shell Builtins137799 +Node: Bash Builtins159260 +Node: Modifying Shell Behavior190116 +Node: The Set Builtin190461 +Node: The Shopt Builtin201003 +Node: Special Builtins216717 +Node: Shell Variables217696 +Node: Bourne Shell Variables218133 +Node: Bash Variables220237 +Node: Bash Features253052 +Node: Invoking Bash254065 +Node: Bash Startup Files260078 +Node: Interactive Shells265181 +Node: What is an Interactive Shell?265591 +Node: Is this Shell Interactive?266240 +Node: Interactive Shell Behavior267055 +Node: Bash Conditional Expressions270684 +Node: Shell Arithmetic275326 +Node: Aliases278270 +Node: Arrays280883 +Node: The Directory Stack287130 +Node: Directory Stack Builtins287914 +Node: Controlling the Prompt292174 +Node: The Restricted Shell295139 +Node: Bash POSIX Mode297749 +Node: Shell Compatibility Mode309022 +Node: Job Control317051 +Node: Job Control Basics317511 +Node: Job Control Builtins322513 +Node: Job Control Variables327913 +Node: Command Line Editing329069 +Node: Introduction and Notation330740 +Node: Readline Interaction332363 +Node: Readline Bare Essentials333554 +Node: Readline Movement Commands335337 +Node: Readline Killing Commands336297 +Node: Readline Arguments338215 +Node: Searching339259 +Node: Readline Init File341445 +Node: Readline Init File Syntax342706 +Node: Conditional Init Constructs364194 +Node: Sample Init File368390 +Node: Bindable Readline Commands371514 +Node: Commands For Moving372718 +Node: Commands For History374769 +Node: Commands For Text379763 +Node: Commands For Killing383412 +Node: Numeric Arguments386445 +Node: Commands For Completion387584 +Node: Keyboard Macros391775 +Node: Miscellaneous Commands392462 +Node: Readline vi Mode398401 +Node: Programmable Completion399308 +Node: Programmable Completion Builtins407088 +Node: A Programmable Completion Example417783 +Node: Using History Interactively423030 +Node: Bash History Facilities423714 +Node: Bash History Builtins426719 +Node: History Interaction431727 +Node: Event Designators435347 +Node: Word Designators436701 +Node: Modifiers438461 +Node: Installing Bash440272 +Node: Basic Installation441409 +Node: Compilers and Options445131 +Node: Compiling For Multiple Architectures445872 +Node: Installation Names447565 +Node: Specifying the System Type449674 +Node: Sharing Defaults450390 +Node: Operation Controls451063 +Node: Optional Features452021 +Node: Reporting Bugs463239 +Node: Major Differences From The Bourne Shell464514 +Node: GNU Free Documentation License481364 +Node: Indexes506541 +Node: Builtin Index506995 +Node: Reserved Word Index513822 +Node: Variable Index516270 +Node: Function Index532762 +Node: Concept Index546546  End Tag Table diff --git a/doc/bashref.texi b/doc/bashref.texi index bd45aa555..a0b7ce5a9 100644 --- a/doc/bashref.texi +++ b/doc/bashref.texi @@ -8539,9 +8539,35 @@ when the @option{-l} option is supplied. @item compat51 (set using BASH_COMPAT) @itemize @bullet @item -The @code{unset} builtin treats attempts to unset array subscripts @samp{@@} -and @samp{*} differently depending on whether the array is indexed or -associative, and differently than in previous versions. +The @code{unset} builtin will unset the array @code{a} given an argument like +@samp{a[@@]}. +Bash-5.2 will unset an element with key @samp{@@} (associative arrays) +or remove all the elements without unsetting the array (indexed arrays) +@item +arithmetic commands ( ((...)) ) and the expressions in an arithmetic for +statement can be expanded more than once +@item +expressions used as arguments to arithmetic operators in the @code{[[} +conditional command can be expanded more than once +@item +the expressions in substring parameter brace expansion can be +expanded more than once +@item +the expressions in the $(( ... )) word expansion can be expanded +more than once +@item +arithmetic expressions used as indexed array subscripts can be +expanded more than once +@item +@code{test -v}, when given an argument of @samp{A[@@]}, where @var{A} is +an existing associative array, will return true if the array has any set +elements. +Bash-5.2 will look for and report on a key named @samp{@@} +@item +the $@{@var{parameter}[:]=@var{value}@} word expansion will return +@var{value}, before any variable-specific transformations have been +performed (e.g., converting to lowercase). +Bash-5.2 will return the final value assigned to the variable. @end itemize @end table diff --git a/doc/version.texi b/doc/version.texi index f10fd8b0f..248ea17d0 100644 --- a/doc/version.texi +++ b/doc/version.texi @@ -2,10 +2,10 @@ Copyright (C) 1988-2021 Free Software Foundation, Inc. @end ignore -@set LASTCHANGE Mon Nov 22 09:58:18 EST 2021 +@set LASTCHANGE Thu Dec 2 15:07:19 EST 2021 @set EDITION 5.2 @set VERSION 5.2 -@set UPDATED 22 November 2021 -@set UPDATED-MONTH November 2021 +@set UPDATED 2 December 2021 +@set UPDATED-MONTH December 2021 diff --git a/examples/loadables/getconf.c b/examples/loadables/getconf.c index 8ca13ca5a..75a0a5679 100644 --- a/examples/loadables/getconf.c +++ b/examples/loadables/getconf.c @@ -97,11 +97,17 @@ static const struct conf vars[] = #ifdef _PC_SOCK_MAXBUF { "SOCK_MAXBUF", _PC_SOCK_MAXBUF, PATHCONF }, #endif +#ifdef _PC_ASYNC_IO { "_POSIX_ASYNC_IO", _PC_ASYNC_IO, PATHCONF }, +#endif { "_POSIX_CHOWN_RESTRICTED", _PC_CHOWN_RESTRICTED, PATHCONF }, { "_POSIX_NO_TRUNC", _PC_NO_TRUNC, PATHCONF }, +#ifdef _PC_PRIO_IO { "_POSIX_PRIO_IO", _PC_PRIO_IO, PATHCONF }, +#endif +#ifdef _PC_SYNC_IO { "_POSIX_SYNC_IO", _PC_SYNC_IO, PATHCONF }, +#endif { "_POSIX_VDISABLE", _PC_VDISABLE, PATHCONF }, { "ARG_MAX", _SC_ARG_MAX, SYSCONF }, @@ -188,7 +194,9 @@ static const struct conf vars[] = { "OPEN_MAX", _SC_OPEN_MAX, SYSCONF }, { "PAGESIZE", _SC_PAGESIZE, SYSCONF }, { "PAGE_SIZE", _SC_PAGESIZE, SYSCONF }, +#ifdef _SC_PASS_MAX { "PASS_MAX", _SC_PASS_MAX, SYSCONF }, +#endif { "PTHREAD_DESTRUCTOR_ITERATIONS", _SC_THREAD_DESTRUCTOR_ITERATIONS, SYSCONF }, { "PTHREAD_KEYS_MAX", _SC_THREAD_KEYS_MAX, SYSCONF }, { "PTHREAD_STACK_MIN", _SC_THREAD_STACK_MIN, SYSCONF }, @@ -317,7 +325,9 @@ static const struct conf vars[] = #ifdef _SC_POLL { "_POSIX_POLL", _SC_POLL, SYSCONF }, #endif +#ifdef _SC_PRIORITIZED_IO { "_POSIX_PRIORITIZED_IO", _SC_PRIORITIZED_IO, SYSCONF }, +#endif { "_POSIX_PRIORITY_SCHEDULING", _SC_PRIORITY_SCHEDULING, SYSCONF }, { "_POSIX_REALTIME_SIGNALS", _SC_REALTIME_SIGNALS, SYSCONF }, { "_POSIX_SAVED_IDS", _SC_SAVED_IDS, SYSCONF }, @@ -366,15 +376,33 @@ static const struct conf vars[] = #ifdef _SC_T_IOV_MAX { "_T_IOV_MAX", _SC_T_IOV_MAX, SYSCONF }, #endif +#ifdef _SC_XOPEN_CRYPT { "_XOPEN_CRYPT", _SC_XOPEN_CRYPT, SYSCONF }, +#endif +#ifdef _SC_XOPEN_ENH_I18N { "_XOPEN_ENH_I18N", _SC_XOPEN_ENH_I18N, SYSCONF }, +#endif +#ifdef _SC_XOPEN_LEGACY { "_XOPEN_LEGACY", _SC_XOPEN_LEGACY, SYSCONF }, +#endif +#ifdef _SC_XOPEN_REALTIME { "_XOPEN_REALTIME", _SC_XOPEN_REALTIME, SYSCONF }, +#endif +#ifdef _SC_XOPEN_REALTIME_THREADS { "_XOPEN_REALTIME_THREADS", _SC_XOPEN_REALTIME_THREADS, SYSCONF }, +#endif +#ifdef _SC_XOPEN_SHM { "_XOPEN_SHM", _SC_XOPEN_SHM, SYSCONF }, +#endif +#ifdef _SC_XOPEN_UNIX { "_XOPEN_UNIX", _SC_XOPEN_UNIX, SYSCONF }, +#endif +#ifdef _SC_XOPEN_VERSION { "_XOPEN_VERSION", _SC_XOPEN_VERSION, SYSCONF }, +#endif +#ifdef _SC_XOPEN_XCU_VERSION { "_XOPEN_XCU_VERSION", _SC_XOPEN_XCU_VERSION, SYSCONF }, +#endif #ifdef _SC_XOPEN_XPG2 { "_XOPEN_XPG2", _SC_XOPEN_XPG2, SYSCONF }, #endif @@ -699,7 +727,9 @@ static const struct conf vars[] = { "POSIX_V7_LPBIG_OFFBIG_LINTFLAGS", _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS, CONFSTR }, #endif +#ifdef _SC_ADVISORY_INFO { "_POSIX_ADVISORY_INFO", _SC_ADVISORY_INFO, SYSCONF }, +#endif #ifdef _SC_BARRIERS { "_POSIX_BARRIERS", _SC_BARRIERS, SYSCONF }, #endif @@ -733,7 +763,9 @@ static const struct conf vars[] = #ifdef _SC_FILE_ATTRIBUTES { "_POSIX_FILE_ATTRIBUTES", _SC_FILE_ATTRIBUTES, SYSCONF }, #endif +#ifdef _SC_FILE_LOCKING { "_POSIX_FILE_LOCKING", _SC_FILE_LOCKING, SYSCONF }, +#endif #ifdef _SC_FILE_SYSTEM { "_POSIX_FILE_SYSTEM", _SC_FILE_SYSTEM, SYSCONF }, #endif @@ -758,16 +790,24 @@ static const struct conf vars[] = { "_POSIX_SIGNALS", _SC_SIGNALS, SYSCONF }, #endif { "_POSIX_SPAWN", _SC_SPAWN, SYSCONF }, +#ifdef _SC_SPORADIC_SERVER { "_POSIX_SPORADIC_SERVER", _SC_SPORADIC_SERVER, SYSCONF }, +#endif +#ifdef _SC_THREAD_SPORADIC_SERVER { "_POSIX_THREAD_SPORADIC_SERVER", _SC_THREAD_SPORADIC_SERVER, SYSCONF }, +#endif #ifdef _SC_SYSTEM_DATABASE { "_POSIX_SYSTEM_DATABASE", _SC_SYSTEM_DATABASE, SYSCONF }, #endif #ifdef _SC_SYSTEM_DATABASE_R { "_POSIX_SYSTEM_DATABASE_R", _SC_SYSTEM_DATABASE_R, SYSCONF }, #endif +#ifdef _SC_TIMEOUTS { "_POSIX_TIMEOUTS", _SC_TIMEOUTS, SYSCONF }, +#endif +#ifdef _SC_TYPED_MEMORY_OBJECTS { "_POSIX_TYPED_MEMORY_OBJECTS", _SC_TYPED_MEMORY_OBJECTS, SYSCONF }, +#endif #ifdef _SC_USER_GROUPS { "_POSIX_USER_GROUPS", _SC_USER_GROUPS, SYSCONF }, #endif @@ -783,7 +823,9 @@ static const struct conf vars[] = { "STREAM_MAX", _SC_STREAM_MAX, SYSCONF }, { "AIO_LISTIO_MAX", _SC_AIO_LISTIO_MAX, SYSCONF }, { "AIO_MAX", _SC_AIO_MAX, SYSCONF }, +#ifdef _SC_AIO_PRIO_DELTA_MAX { "AIO_PRIO_DELTA_MAX", _SC_AIO_PRIO_DELTA_MAX, SYSCONF }, +#endif { "DELAYTIMER_MAX", _SC_DELAYTIMER_MAX, SYSCONF }, { "HOST_NAME_MAX", _SC_HOST_NAME_MAX, SYSCONF }, { "LOGIN_NAME_MAX", _SC_LOGIN_NAME_MAX, SYSCONF }, @@ -792,22 +834,46 @@ static const struct conf vars[] = #ifdef _SC_DEVICE_IO { "_POSIX_DEVICE_IO", _SC_DEVICE_IO, SYSCONF }, #endif +#ifdef _SC_TRACE { "_POSIX_TRACE", _SC_TRACE, SYSCONF }, +#endif +#ifdef _SC_TRACE_EVENT_FILTER { "_POSIX_TRACE_EVENT_FILTER", _SC_TRACE_EVENT_FILTER, SYSCONF }, +#endif +#ifdef _SC_TRACE_INHERIT { "_POSIX_TRACE_INHERIT", _SC_TRACE_INHERIT, SYSCONF }, +#endif +#ifdef _SC_TRACE_LOG { "_POSIX_TRACE_LOG", _SC_TRACE_LOG, SYSCONF }, +#endif { "RTSIG_MAX", _SC_RTSIG_MAX, SYSCONF }, +#ifdef _SC_SEM_NSEMS_MAX { "SEM_NSEMS_MAX", _SC_SEM_NSEMS_MAX, SYSCONF }, +#endif +#ifdef _SC_SEM_VALUE_MAX { "SEM_VALUE_MAX", _SC_SEM_VALUE_MAX, SYSCONF }, +#endif { "SIGQUEUE_MAX", _SC_SIGQUEUE_MAX, SYSCONF }, { "FILESIZEBITS", _PC_FILESIZEBITS, PATHCONF }, +#ifdef _PC_ALLOC_SIZE_MIN { "POSIX_ALLOC_SIZE_MIN", _PC_ALLOC_SIZE_MIN, PATHCONF }, +#endif +#ifdef _PC_REC_INCR_XFER_SIZE { "POSIX_REC_INCR_XFER_SIZE", _PC_REC_INCR_XFER_SIZE, PATHCONF }, +#endif +#ifdef _PC_REC_MAX_XFER_SIZE { "POSIX_REC_MAX_XFER_SIZE", _PC_REC_MAX_XFER_SIZE, PATHCONF }, +#endif +#ifdef _PC_REC_MIN_XFER_SIZE { "POSIX_REC_MIN_XFER_SIZE", _PC_REC_MIN_XFER_SIZE, PATHCONF }, +#endif +#ifdef _PC_REC_XFER_ALIGN { "POSIX_REC_XFER_ALIGN", _PC_REC_XFER_ALIGN, PATHCONF }, +#endif { "SYMLINK_MAX", _PC_SYMLINK_MAX, PATHCONF }, +#ifdef _PC_2_SYMLINKS { "POSIX2_SYMLINKS", _PC_2_SYMLINKS, PATHCONF }, +#endif #ifdef _SC_LEVEL1_ICACHE_SIZE { "LEVEL1_ICACHE_SIZE", _SC_LEVEL1_ICACHE_SIZE, SYSCONF }, @@ -833,11 +899,14 @@ static const struct conf vars[] = { "LEVEL4_CACHE_LINESIZE", _SC_LEVEL4_CACHE_LINESIZE, SYSCONF }, #endif +#ifdef _SC_IPV6 { "IPV6", _SC_IPV6, SYSCONF }, - { "RAW_SOCKETS", _SC_RAW_SOCKETS, SYSCONF }, - { "_POSIX_IPV6", _SC_IPV6, SYSCONF }, +#endif +#ifdef _SC_RAW_SOCKETS + { "RAW_SOCKETS", _SC_RAW_SOCKETS, SYSCONF }, { "_POSIX_RAW_SOCKETS", _SC_RAW_SOCKETS, SYSCONF }, +#endif { NULL, 0, SYSCONF } }; diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c index 06983c745..146d7f23e 100644 --- a/lib/malloc/malloc.c +++ b/lib/malloc/malloc.c @@ -242,6 +242,12 @@ typedef union _malloc_guard { # define MMAP_THRESHOLD (8 * SIZEOF_LONG) #endif +/* We don't try to decipher the differences between the Linux-style and + BSD-style implementations of mremap here; we use the Linux one. */ +#if USE_MMAP == 1 && defined (HAVE_MREMAP) && defined (MREMAP_MAYMOVE) +# define USE_MREMAP 1 +#endif + /* usable bins from STARTBUCK..NBUCKETS-1 */ #define NBUCKETS 28 @@ -1083,7 +1089,7 @@ free_return: #endif } -#if USE_MMAP == 1 && defined (HAVE_MREMAP) +#if USE_MREMAP == 1 /* Assume the caller (internal_realloc) has already performed the sanity and overflow tests. Basically we kill the old guard information, determine the new size, call mremap with the new size, and add the bookkeeping and guard @@ -1240,9 +1246,9 @@ internal_realloc (mem, n, file, line, flags) _mstats.nrcopy++; #endif +#if USE_MREMAP == 1 /* If we are using mmap and have mremap, we use it here. Make sure that the old size and new size are above the threshold where we use mmap */ -#if USE_MMAP == 1 && defined (HAVE_MREMAP) if (nbytes > p->mh_nbytes) newunits = nunits; else @@ -1258,7 +1264,7 @@ internal_realloc (mem, n, file, line, flags) return 0; } else -#endif +#endif /* USE_MREMAP */ { if ((m = internal_malloc (n, file, line, MALLOC_INTERNAL|MALLOC_NOTRACE|MALLOC_NOREG)) == 0) return 0; diff --git a/subst.c b/subst.c index 139346cdd..20755b6fe 100644 --- a/subst.c +++ b/subst.c @@ -7627,11 +7627,7 @@ verify_substring_values (v, value, substr, vtype, e1p, e2p) t = (char *)0; temp1 = expand_arith_string (substr, Q_DOUBLE_QUOTES|Q_ARITH); -#if 0 /* TAG: bash-5.2 */ eflag = (shell_compatibility_level > 51) ? 0 : EXP_EXPANDED; -#else - eflag = 0; -#endif *e1p = evalexp (temp1, eflag, &expok); free (temp1); @@ -10064,11 +10060,8 @@ arithsub: /* No error messages. */ savecmd = this_command_name; this_command_name = (char *)NULL; -#if 0 /* TAG: bash-5.2 */ + eflag = (shell_compatibility_level > 51) ? 0 : EXP_EXPANDED; -#else - eflag = 0; -#endif number = evalexp (temp1, eflag, &expok); this_command_name = savecmd; free (temp); @@ -10552,11 +10545,7 @@ add_string: #if defined (ARRAY_VARS) case '[': /*]*/ -#if 0 /* TAG:bash-5.2 */ if ((quoted & Q_ARITH) == 0 || shell_compatibility_level <= 51) -#else - if ((quoted & Q_ARITH) == 0) -#endif { if (isexp == 0 && (word->flags & (W_NOSPLIT|W_NOSPLIT2)) == 0 && isifs (c) && (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) == 0) goto add_ifs_character; diff --git a/support/shobj-conf b/support/shobj-conf index acbb344eb..cd7634dfa 100644 --- a/support/shobj-conf +++ b/support/shobj-conf @@ -123,7 +123,7 @@ sunos5*|solaris2*) ;; # All versions of Linux (including Gentoo/FreeBSD) or the semi-mythical GNU Hurd. -linux*-*|gnu*-*|k*bsd*-gnu-*|midnightbsd*freebsd*|dragonfly*) +linux*-*|gnu*-*|k*bsd*-gnu-*|midnightbsd*|freebsd*|dragonfly*) SHOBJ_CFLAGS=-fPIC SHOBJ_LD='${CC}' SHOBJ_LDFLAGS='-shared -Wl,-soname,$@' diff --git a/test.c b/test.c index 1cc22e324..6a6dfd81b 100644 --- a/test.c +++ b/test.c @@ -639,10 +639,7 @@ unary_test (op, arg, flags) /* XXX - TAG:bash-5.2 fix with corresponding fix to execute_cmd.c: execute_cond_node() that passes TEST_ARRAYEXP in FLAGS */ -#if 0 - /* TAG:bash-5.2 */ if (shell_compatibility_level > 51) -#endif /* Allow associative arrays to use `test -v array[@]' to look for a key named `@'. */ aflags |= AV_ATSTARKEYS;