From: Chet Ramey Date: Mon, 22 Oct 2018 20:47:48 +0000 (-0400) Subject: commit bash-20181019 snapshot X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b577a7bc742b7085b9a7bb1f1a90767da58c71be;p=thirdparty%2Fbash.git commit bash-20181019 snapshot --- diff --git a/CHANGES b/CHANGES index bce097c40..fb8e622a0 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,66 @@ This document details the changes between this version, bash-5.0-beta, and the previous version, bash-5.0-alpha. +1. Changes to Bash + +a. Fixed a bug that could cause a seg fault while parsing a subshell command + inside a command substitution. + +b. Fixed several small memory leaks uncovered by coverity. + +c. Fixed a problem with command substitution inside an interactive shell that + could cause the parent to receive a SIGHUP. + +d. Fixed a problem with using `*' and `@' as subscripts when assigning values + to an associative array with assoc_expand_once enabled. + +e. Fixed a bug that could cause a huge memory allocation when completing a + word beginning with an invalid tilde expansion. + +f. Cleaned up some incompatiblities with bash-4.4 when expanding indexed array + subscripts used in arithmetic expansions when assoc_expand_once is enabled. + +g. The ${parameter@a} expansion will display attributes even if `parameter' is + unset. + +2. Changes to Readline + +a. Fixed a bug with adding multibyte characters to an incremental search string. + +b. Fixed a bug with redoing text insertions in vi mode. + +c. Fixed a bug with pasting text into an incremental search string if bracketed + paste mode is enabled. ESC cannot be one of the incremental search + terminator characters for this to work. + +3. New Features in Bash + +a. Associative and indexed arrays now allow subscripts consisting solely of + whitespace. + +b. `checkwinsize' is now enabled by default. + +c. The `localvar_unset' shopt option is now visible and documented. + +d. The `progcomp_alias' shopt option is now visible and documented. + +e. The signal name processing code now understands `SIGRTMIN+n' all the way + up to SIGRTMAX. + +f. There is a new `seq' loadable builtin. + +g. Trap execution now honors the (internal) max invocations of `eval', since + traps are supposed to be executed as if using `eval'. + +4. New Features in Readline + +a. Readline now allows application-defined keymap names; there is a new public + function, rl_set_keymap_name(), to do that. + +------------------------------------------------------------------------------ +This document details the changes between this version, bash-5.0-beta, and +the previous version, bash-5.0-alpha. + 1. Changes to Bash a. Fixed a bug that allowed subshells to "inherit" enclosing loops -- this diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 3a6d4832b..930624435 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -4587,3 +4587,31 @@ arrayfunc.c array subscript -- we already figure out whether or not we are [bumped release status to beta2] + + 10/20 + ----- +builtins/setattr.def + - set_or_show_attributes: after isolating NAME, make sure to restore + the "[+]=" in case we need the word later. Issue pointed out by + Grisha Levit + + 10/21 + ----- +lib/readline/search.c + - noninc_search_from_pos: if we are supposed to be searching for a + pattern (vi mode), make sure to pass S to _hs_history_patsearch, + since that has any leading `^' stripped + +lib/readline/histsearch.c + - _hs_history_patsearch: if the search isn't anchored, put a `*' at + the beginning to force fnmatch to match anywhere in the line (could + look at this later to make a change to history_search_internal that + would avoid the need to add the leading `*') + +subst.c + - parameter_brace_expand_rhs: treat a failure to assign a variable with + a ${param:=value} expansion as an expansion error, and, in a non- + interactive posix-mode shell, exit the shell + - param_expand: don't set W_SPLITSPACE for $* unless IFS is NULL; + consistent with other uses of W_SPLITSPACE + diff --git a/builtins/setattr.def b/builtins/setattr.def index 1e35afcac..251bcacbc 100644 --- a/builtins/setattr.def +++ b/builtins/setattr.def @@ -277,6 +277,12 @@ set_or_show_attributes (list, attribute, nodefs) } set_var_attribute (name, attribute, undo); + if (assign) /* restore word */ + { + name[assign] = '='; + if (aflags & ASS_APPEND) + name[assign-1] = '+'; + } list = list->next; } } diff --git a/execute_cmd.c b/execute_cmd.c index 045863302..4c2b15cd2 100644 --- a/execute_cmd.c +++ b/execute_cmd.c @@ -3473,9 +3473,31 @@ execute_case_command (case_command) } #endif +#if 0 /* TAG: bash-5.1 */ + /* Use the same expansions (POSIX leaves them unspecified) as the patterns + but dequote the resulting string, since the quotes are handled specially + below. */ + if (posixly_correct) + { + wlist = expand_word_leave_quoted (case_command->word, 0); + if (wlist) + { + char *t; + t = string_list (wlist); + word = dequote_string (t); + free (t); + } + else + word = savestring (""); + dispose_words (wlist); + } + else +#endif + { wlist = expand_word_unsplit (case_command->word, 0); word = wlist ? string_list (wlist) : savestring (""); dispose_words (wlist); + } retval = EXECUTION_SUCCESS; ignore_return = case_command->flags & CMD_IGNORE_RETURN; diff --git a/lib/readline/histsearch.c b/lib/readline/histsearch.c index b6771fda2..7a426c967 100644 --- a/lib/readline/histsearch.c +++ b/lib/readline/histsearch.c @@ -199,7 +199,7 @@ int _hs_history_patsearch (const char *string, int direction, int flags) { char *pat; - size_t len; + size_t len, start; int ret, unescaped_backslash; #if defined (HAVE_FNMATCH) @@ -216,12 +216,26 @@ _hs_history_patsearch (const char *string, int direction, int flags) } if (unescaped_backslash) return -1; - pat = (char *)xmalloc (len + 2); + pat = (char *)xmalloc (len + 3); + /* If the search string is not anchored, we'll be calling fnmatch (assuming + we have it). Prefix a `*' to the front of the search string so we search + anywhere in the line. */ + if ((flags & ANCHORED_SEARCH) == 0 && string[0] != '*') + { + pat[0] = '*'; + start = 1; + len++; + } + else + { + start = 0; + } + /* Attempt to reduce the number of searches by tacking a `*' onto the end of a pattern that doesn't have one. Assume a pattern that ends in a backslash contains an even number of trailing backslashes; we check above */ - strcpy (pat, string); + strcpy (pat + start, string); if (pat[len - 1] != '*') { pat[len] = '*'; /* XXX */ diff --git a/lib/readline/search.c b/lib/readline/search.c index 649256114..c9c1f5d1d 100644 --- a/lib/readline/search.c +++ b/lib/readline/search.c @@ -135,7 +135,7 @@ noninc_search_from_pos (char *string, int pos, int dir, int flags, int *ncp) sflags |= ANCHORED_SEARCH; s++; } - ret = _hs_history_patsearch (string, dir, sflags); + ret = _hs_history_patsearch (s, dir, sflags); } else if (*string == '^') ret = history_search_prefix (string + 1, dir); diff --git a/po/pt.po b/po/pt.po index 2678c9b76..244170b01 100644 --- a/po/pt.po +++ b/po/pt.po @@ -12,10 +12,10 @@ msgstr "" "Last-Translator: Pedro Albuquerque \n" "Language-Team: Portuguese \n" "Language: pt\n" -"X-Bugs: Report translation errors to the Language-Team address.\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" +"X-Bugs: Report translation errors to the Language-Team address.\n" "Plural-Forms: nplurals=2; plural=n !=1;\n" "X-Generator: Gtranslator 2.91.6\n" @@ -542,7 +542,7 @@ msgstr "posição do histórico" #: builtins/history.def:264 #, c-format msgid "%s: invalid timestamp" -msgstr "%s: carimbo inválido" +msgstr "%s: datação inválida" #: builtins/history.def:375 #, c-format @@ -4233,7 +4233,7 @@ msgstr "" " EXPR1 -o EXPR2 Verdadeiro se EXPR1 OU EXPR2 forem verdadeiros.\n" " \n" " arg1 OP arg2 Testes aritméticos. OP é um de -eq, -ne,\n" -"  -lt, -le, -gt, ou -ge.\n" +" -lt, -le, -gt, ou -ge.\n" " \n" " Operadores binários aritméticos devolvem verdadeiro se ARG1 for igual, não\n" " igual, menor que, menor ou igual que, maior que ou maior ou igual que\n" diff --git a/subst.c b/subst.c index 34be5ff9d..267aaea73 100644 --- a/subst.c +++ b/subst.c @@ -4276,6 +4276,21 @@ quote_list (list) return list; } +WORD_DESC * +dequote_word (word) + WORD_DESC *word; +{ + register char *s; + + s = dequote_string (word->word); + if (QUOTED_NULL (word->word)) + word->flags &= ~W_HASQUOTEDNULL; + free (word->word); + word->word = s; + + return word; +} + /* De-quote quoted characters in each word in LIST. */ WORD_LIST * dequote_list (list) @@ -6821,6 +6836,7 @@ parameter_brace_expand_rhs (name, value, op, quoted, pflags, qdollaratp, hasdoll WORD_LIST *l; char *t, *t1, *temp, *vname; int l_hasdollat, sindex; + SHELL_VAR *v; /*itrace("parameter_brace_expand_rhs: %s:%s pflags = %d", name, value, pflags);*/ /* If the entire expression is between double quotes, we want to treat @@ -6950,10 +6966,26 @@ parameter_brace_expand_rhs (name, value, op, quoted, pflags, qdollaratp, hasdoll #if defined (ARRAY_VARS) if (valid_array_reference (vname, 0)) - assign_array_element (vname, t1, 0); + v = assign_array_element (vname, t1, 0); else #endif /* ARRAY_VARS */ - bind_variable (vname, t1, 0); + v = bind_variable (vname, t1, 0); + + if (v == 0 || readonly_p (v) || noassign_p (v)) /* expansion error */ + { + if ((v == 0 || readonly_p (v)) && interactive_shell == 0 && posixly_correct) + { + last_command_exit_value = EXECUTION_FAILURE; + exp_jump_to_top_level (FORCE_EOF); + } + else + { + if (vname != name) + free (vname); + last_command_exit_value = EX_BADUSAGE; + exp_jump_to_top_level (DISCARD); + } + } stupidly_hack_special_variables (vname); @@ -9244,7 +9276,11 @@ param_expand (string, sindex, quoted, expanded_something, temp = string_list_dollar_at (list, quoted, 0); /* Set W_SPLITSPACE to make sure the individual positional parameters are split into separate arguments */ +#if 0 if (quoted == 0 && (ifs_is_set == 0 || ifs_is_null)) +#else /* change with bash-5.0 */ + if (quoted == 0 && ifs_is_null) +#endif tflag |= W_SPLITSPACE; /* If we're not quoted but we still don't want word splitting, make we quote the IFS characters to protect them from splitting (e.g., diff --git a/subst.h b/subst.h index 7530dc6e9..34763222e 100644 --- a/subst.h +++ b/subst.h @@ -194,6 +194,8 @@ extern char *dequote_string __P((char *)); /* De-quote CTLESC-escaped CTLESC or CTLNUL characters in STRING. */ extern char *dequote_escapes __P((const char *)); +extern WORD_DESC *dequote_word __P((WORD_DESC *)); + /* De-quote quoted characters in each word in LIST. */ extern WORD_LIST *dequote_list __P((WORD_LIST *));