Bash-5.2 official patch 9
BASH PATCH REPORT = Bash-Release: 5.2 Patch-ID: bash52-009 Bug-Reported-by:Corey Hickey Bug-Reference-ID: <134330ef-0ead-d73e-68eb-d58fc51ef...@fatooh.org> Bug-Reference-URL: https://lists.gnu.org/archive/html/help-bash/2022-10/msg00025.html Bug-Description: Bash arithmetic expansion should allow `@' and `*' to be used as associative array keys in expressions. Patch (apply with `patch -p0'): *** ../bash-5.2-patched/expr.c 2022-07-11 10:03:34.0 -0400 --- expr.c 2022-10-31 10:51:08.0 -0400 *** *** 1169,1172 --- 1169,1174 #if defined (ARRAY_VARS) aflag = tflag; /* use a different variable for now */ + if (shell_compatibility_level > 51) + aflag |= AV_ATSTARKEYS; v = (e == ']') ? array_variable_part (tok, tflag, (char **)0, (int *)0) : find_variable (tok); #else *** ../bash-5.2/patchlevel.h2020-06-22 14:51:03.0 -0400 --- patchlevel.h2020-10-01 11:01:28.0 -0400 *** *** 26,30 looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 8 #endif /* _PATCHLEVEL_H_ */ --- 26,30 looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 9 #endif /* _PATCHLEVEL_H_ */ -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Bash-5.2 official patch 8
BASH PATCH REPORT = Bash-Release: 5.2 Patch-ID: bash52-008 Bug-Reported-by:Glenn Jackman Bug-Reference-ID: Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00095.html Bug-Description: Array subscript expansion can inappropriately quote brackets if the expression contains < or >. Patch (apply with `patch -p0'): *** ../bash-20221015/subst.c2022-10-18 10:47:33.0 -0500 --- subst.c 2022-10-20 11:41:07.0 -0500 *** *** 3820,3823 --- 3820,3827 #endif + /* We don't perform process substitution in arithmetic expressions, so don't +bother checking for it. */ + #define ARITH_EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC || s == '~') + /* If there are any characters in STRING that require full expansion, then call FUNC to expand STRING; otherwise just perform quote *** *** 4029,4033 while (string[i]) { ! if (EXP_CHAR (string[i])) break; else if (string[i] == '\'' || string[i] == '\\' || string[i] == '"') --- 4033,4037 while (string[i]) { ! if (ARITH_EXP_CHAR (string[i])) break; else if (string[i] == '\'' || string[i] == '\\' || string[i] == '"') *** ../bash-5.2/patchlevel.h2020-06-22 14:51:03.0 -0400 --- patchlevel.h2020-10-01 11:01:28.0 -0400 *** *** 26,30 looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 7 #endif /* _PATCHLEVEL_H_ */ --- 26,30 looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 8 #endif /* _PATCHLEVEL_H_ */ -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Bash-5.2 official patch 7
BASH PATCH REPORT = Bash-Release: 5.2 Patch-ID: bash52-007 Bug-Reported-by:Bruce Jerrick Bug-Reference-ID: Bug-Reference-URL: https://bugzilla.redhat.com/show_bug.cgi?id=2134307 Bug-Description: This patch fixes several problems with alias expansion inside command substitutions when in POSIX mode. Patch (apply with `patch -p0'): *** /fs1/chet/scratch/bash-5.2.6/parse.y2022-11-02 10:36:54.0 -0400 --- parse.y 2022-10-24 10:53:26.0 -0400 *** *** 3613,3616 --- 3614,3618 #define P_ARRAYSUB0x0020 /* parsing a [...] array subscript for assignment */ #define P_DOLBRACE0x0040 /* parsing a ${...} construct */ + #define P_ARITH 0x0080 /* parsing a $(( )) arithmetic expansion */ /* Lexical state while parsing a grouping construct or $(...). */ *** *** 3911,3914 --- 3914,3920 else if ((flags & (P_ARRAYSUB|P_DOLBRACE)) && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ goto parse_dollar_word; + else if ((flags & P_ARITH) && (tflags & LEX_WASDOL) && ch == '(') /*)*/ + /* $() inside $(( ))/$[ ] */ + goto parse_dollar_word; #if defined (PROCESS_SUBSTITUTION) /* XXX - technically this should only be recognized at the start of *** *** 3941,3945 nestret = parse_matched_pair (0, '{', '}', , P_FIRSTCLOSE|P_DOLBRACE|rflags); else if (ch == '[') /* ] */ ! nestret = parse_matched_pair (0, '[', ']', , rflags); CHECK_NESTRET_ERROR (); --- 3947,3951 nestret = parse_matched_pair (0, '{', '}', , P_FIRSTCLOSE|P_DOLBRACE|rflags); else if (ch == '[') /* ] */ ! nestret = parse_matched_pair (0, '[', ']', , rflags|P_ARITH); CHECK_NESTRET_ERROR (); *** *** 4080,4084 shell_ungetc (peekc); if (peekc == '(') /*)*/ ! return (parse_matched_pair (qc, open, close, lenp, 0)); } --- 4086,4090 shell_ungetc (peekc); if (peekc == '(') /*)*/ ! return (parse_matched_pair (qc, open, close, lenp, P_ARITH)); } *** *** 4501,4505 exp_lineno = line_number; ! ttok = parse_matched_pair (0, '(', ')', , 0); rval = 1; if (ttok == _pair_error) --- 4512,4516 exp_lineno = line_number; ! ttok = parse_matched_pair (0, '(', ')', , P_ARITH); rval = 1; if (ttok == _pair_error) *** *** 5016,5020 } else ! ttok = parse_matched_pair (cd, '[', ']', , 0); if (ttok == _pair_error) return -1; /* Bail immediately. */ --- 5030,5034 } else ! ttok = parse_matched_pair (cd, '[', ']', , P_ARITH); if (ttok == _pair_error) return -1; /* Bail immediately. */ *** ../bash-5.2.6/y.tab.c 2022-11-02 10:36:54.0 -0400 --- y.tab.c 2022-11-02 10:55:58.0 -0400 *** *** 5924,5927 --- 5924,5928 #define P_ARRAYSUB0x0020 /* parsing a [...] array subscript for assignment */ #define P_DOLBRACE0x0040 /* parsing a ${...} construct */ + #define P_ARITH 0x0080 /* parsing a $(( )) arithmetic expansion */ /* Lexical state while parsing a grouping construct or $(...). */ *** *** 6222,6225 --- 6223,6229 else if ((flags & (P_ARRAYSUB|P_DOLBRACE)) && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ goto parse_dollar_word; + else if ((flags & P_ARITH) && (tflags & LEX_WASDOL) && ch == '(') /*)*/ + /* $() inside $(( ))/$[ ] */ + goto parse_dollar_word; #if defined (PROCESS_SUBSTITUTION) /* XXX - technically this should only be recognized at the start of *** *** 6252,6256 nestret = parse_matched_pair (0, '{', '}', , P_FIRSTCLOSE|P_DOLBRACE|rflags); else if (ch == '[') /* ] */ ! nestret = parse_matched_pair (0, '[', ']', , rflags); CHECK_NESTRET_ERROR (); --- 6256,6260 nestret = parse_matched_pair (0, '{', '}', , P_FIRSTCLOSE|P_DOLBRACE|rflags); else if (ch == '[') /* ] */ ! nestret = parse_matched_pair (0, '[', ']', , rflags|P_ARITH); CHECK_NESTRET_ERROR (); *** *** 6391,6395 shell_ungetc (peekc); if (peekc == '(') /*)*/ ! return (parse_matched_pair (qc, open, close, lenp, 0)); } --- 6395,6399 shell_ungetc (peekc); if (peekc == '(') /*)*/ ! return (parse_matched_pair (qc, open, close, lenp, P_ARITH));
Bash-5.2 official patch 6
BASH PATCH REPORT = Bash-Release: 5.2 Patch-ID: bash52-006 Bug-Reported-by:feng xiangjun Bug-Reference-ID: Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00089.html Bug-Description: In interactive shells, interrupting the shell while entering a command substitution can inhibit alias expansion. Patch (apply with `patch -p0'): *** ../bash-5.2-patched/parse.y 2022-10-08 13:10:06.0 -0400 --- parse.y 2022-10-14 10:03:19.0 -0400 *** *** 3307,3310 --- 3307,3312 extended_glob = global_extglob; #endif + if (parser_state & (PST_CMDSUBST|PST_STRING)) + expand_aliases = expaliases_flag; parser_state = 0; *** *** 4389,4392 --- 4391,4395 parser_state |= PST_NOERROR; + parser_state |= PST_STRING; expand_aliases = 0; *** *** 6402,6406 parser_state &= ~PST_NOEXPAND; /* parse_comsub sentinel */ /* State flags we want to set for this run through the tokenizer. */ ! parser_state |= PST_COMPASSIGN|PST_REPARSE; } --- 6405,6409 parser_state &= ~PST_NOEXPAND; /* parse_comsub sentinel */ /* State flags we want to set for this run through the tokenizer. */ ! parser_state |= PST_COMPASSIGN|PST_REPARSE|PST_STRING; } *** ../bash-20221007/parser.h 2022-08-30 11:39:56.0 -0400 --- parser.h2022-10-14 09:56:18.0 -0400 *** *** 51,54 --- 51,55 #define PST_NOEXPAND 0x40/* don't expand anything in read_token_word; for command substitution */ #define PST_NOERROR 0x80/* don't print error messages in yyerror */ + #define PST_STRING0x100 /* parsing a string to a command or word list */ /* Definition of the delimiter stack. Needed by parse.y and bashhist.c. */ *** ../bash-20221007/builtins/shopt.def 2022-10-07 10:25:55.0 -0400 --- builtins/shopt.def 2022-10-14 09:30:11.0 -0400 *** *** 150,153 --- 150,156 #endif + int expaliases_flag = 0; + static int shopt_set_expaliases PARAMS((char *, int)); + static int shopt_set_debug_mode PARAMS((char *, int)); *** *** 199,203 { "dotglob", _dot_filenames, (shopt_set_func_t *)NULL }, { "execfail", _exit_on_failed_exec, (shopt_set_func_t *)NULL }, ! { "expand_aliases", _aliases, (shopt_set_func_t *)NULL }, #if defined (DEBUGGER) { "extdebug", _mode, shopt_set_debug_mode }, --- 202,206 { "dotglob", _dot_filenames, (shopt_set_func_t *)NULL }, { "execfail", _exit_on_failed_exec, (shopt_set_func_t *)NULL }, ! { "expand_aliases", _flag, shopt_set_expaliases }, #if defined (DEBUGGER) { "extdebug", _mode, shopt_set_debug_mode }, *** *** 351,355 allow_null_glob_expansion = glob_dot_filenames = 0; no_exit_on_failed_exec = 0; ! expand_aliases = 0; extended_quote = 1; fail_glob_expansion = 0; --- 354,358 allow_null_glob_expansion = glob_dot_filenames = 0; no_exit_on_failed_exec = 0; ! expand_aliases = expaliases_flag = 0; extended_quote = 1; fail_glob_expansion = 0; *** *** 632,635 --- 635,647 } + static int + shopt_set_expaliases (option_name, mode) + char *option_name; + int mode; + { + expand_aliases = expaliases_flag; + return 0; + } + #if defined (READLINE) static int *** ../bash-20221007/builtins/common.h 2022-10-07 10:10:17.0 -0400 --- builtins/common.h 2022-10-14 09:29:25.0 -0400 *** *** 258,261 --- 258,263 #endif + extern int expaliases_flag; + /* variables from source.def */ extern int source_searches_cwd; *** ../bash-20221007/execute_cmd.c 2022-10-10 10:48:54.0 -0400 --- execute_cmd.c 2022-10-14 09:32:24.0 -0400 *** *** 1537,1541 aliases. */ if (ois != interactive_shell) ! expand_aliases = 0; } --- 1537,1541 aliases. */ if (ois != interactive_shell) ! expand_aliases = expaliases_flag = 0; } *** ../bash-20221007/general.c 2021-11-04 14:12:38.0 -0400 --- general.c 2022-10-14 09:34:24.0 -0400 *** *** 92,96 _comments, _uses_path, ! _aliases, _errexit, _shift_error, --- 92,96 _comments, _uses_path, ! _flag, _errexit, _shift_error, *** *** 107,111 if (on != 0) { ! interactive_comments = source_uses_path = expand_aliases = 1; inherit_errexit = 1; source_searches_cwd = 0; --- 107,112 if (on != 0) { ! interactive_comments = source_uses_path = 1; ! expand_aliases = expaliases_flag = 1; inherit_errexit = 1; source_searches_cwd = 0; *** *** 117,120 ---
Bash-5.2 official patch 5
BASH PATCH REPORT = Bash-Release: 5.2 Patch-ID: bash52-005 Bug-Reported-by:Justin Wood (Callek) Bug-Reference-ID: Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00088.html Bug-Description: Null pattern substitution replacement strings can cause a crash. Patch (apply with `patch -p0'): *** ../bash-5.2-patched/subst.c 2022-10-05 10:22:02.0 -0400 --- subst.c 2022-10-13 16:57:26.0 -0400 *** *** 8966,8970 } else if (*string == 0 && (match_pattern (string, pat, mtype, , ) != 0)) ! return ((mflags & MATCH_EXPREP) ? strcreplace (rep, '&', "", 2) : savestring (rep)); ret = (char *)xmalloc (rsize = 64); --- 8966,8971 } else if (*string == 0 && (match_pattern (string, pat, mtype, , ) != 0)) ! return (mflags & MATCH_EXPREP) ? strcreplace (rep, '&', "", 2) ! : (rep ? savestring (rep) : savestring ("")); ret = (char *)xmalloc (rsize = 64); *** ../bash-5.2/patchlevel.h2020-06-22 14:51:03.0 -0400 --- patchlevel.h2020-10-01 11:01:28.0 -0400 *** *** 26,30 looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 4 #endif /* _PATCHLEVEL_H_ */ --- 26,30 looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 5 #endif /* _PATCHLEVEL_H_ */ -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Bash-5.2 official patch 4
BASH PATCH REPORT = Bash-Release: 5.2 Patch-ID: bash52-004 Bug-Reported-by:Antoine Bug-Reference-ID: <8bd59753-05ff-9b09-2337-2c7f52ded...@glitchimini.net> Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00022.html Bug-Description: Bash needs to keep better track of nested brace expansions to avoid problems with quoting and POSIX semantics. Patch (apply with `patch -p0'): *** ../bash-5.2-patched/subst.c 2022-10-05 10:22:02.0 -0400 --- subst.c 2022-10-06 15:19:08.0 -0400 *** *** 1799,1802 --- 1804,1810 } + #define PARAMEXPNEST_MAX 32 // for now + static int dbstate[PARAMEXPNEST_MAX]; + /* Extract a parameter expansion expression within ${ and } from STRING. Obey the Posix.2 rules for finding the ending `}': count braces while *** *** 1829,1832 --- 1837,1842 return (extract_heredoc_dolbrace_string (string, sindex, quoted, flags)); + dbstate[0] = dolbrace_state; + pass_character = 0; nesting_level = 1; *** *** 1853,1856 --- 1863,1868 if (string[i] == '$' && string[i+1] == LBRACE) { + if (nesting_level < PARAMEXPNEST_MAX) + dbstate[nesting_level] = dolbrace_state; nesting_level++; i += 2; *** *** 1865,1868 --- 1877,1881 if (nesting_level == 0) break; + dolbrace_state = (nesting_level < PARAMEXPNEST_MAX) ? dbstate[nesting_level] : dbstate[0];/* Guess using initial state */ i++; continue; *** ../bash-5.2/patchlevel.h2020-06-22 14:51:03.0 -0400 --- patchlevel.h2020-10-01 11:01:28.0 -0400 *** *** 26,30 looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 3 #endif /* _PATCHLEVEL_H_ */ --- 26,30 looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 4 #endif /* _PATCHLEVEL_H_ */ -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/
Bash-5.2 official patch 3
BASH PATCH REPORT = Bash-Release: 5.2 Patch-ID: bash52-003 Bug-Reported-by: D630 Bug-Reference-ID: Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00092.html Bug-Description: Command substitutions need to preserve newlines instead of replacing them with semicolons, especially in the presence of multiple here-documents. Patch (apply with `patch -p0'): *** ../bash-5.2-patched/print_cmd.c 2022-07-26 09:16:39.0 -0400 --- print_cmd.c 2022-10-17 10:41:06.0 -0400 *** *** 298,305 --- 298,307 { char c = command->value.Connection->connector; + int was_newline; s[0] = printing_comsub ? c : ';'; s[1] = '\0'; + was_newline = deferred_heredocs == 0 && was_heredoc == 0 && c == '\n'; if (deferred_heredocs == 0) { *** *** 315,318 --- 317,322 if (inside_function_def) cprintf ("\n"); + else if (printing_comsub && c == '\n' && was_newline == 0) + cprintf ("\n"); /* preserve newlines in comsubs but don't double them */ else { *** *** 1366,1370 } else ! newline ("}"); dispose_command (cmdcopy); --- 1371,1379 } else ! { ! /* { */ ! newline ("}"); ! was_heredoc = 0;/* not printing any here-documents now */ ! } dispose_command (cmdcopy); *** *** 1443,1447 } else ! newline ("}"); result = the_printed_command; --- 1452,1459 } else ! { /* { */ ! newline ("}"); ! was_heredoc = 0; ! } result = the_printed_command; *** ../bash-5.2/patchlevel.h2020-06-22 14:51:03.0 -0400 --- patchlevel.h2020-10-01 11:01:28.0 -0400 *** *** 26,30 looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 2 #endif /* _PATCHLEVEL_H_ */ --- 26,30 looks for to find the patch level (for the sccs version string). */ ! #define PATCHLEVEL 3 #endif /* _PATCHLEVEL_H_ */ -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/