From: Chet Ramey Date: Mon, 25 Feb 2019 13:48:43 +0000 (-0500) Subject: commit bash-20190223 snapshot X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3eef85534f4e7868e23cca6536286f24ecebd001;p=thirdparty%2Fbash.git commit bash-20190223 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 4442a20d5..86c626055 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -5358,3 +5358,26 @@ subst.c will eventually be split and we need to preserve the null to produce an empty word. From a discussion on bug-bash started by sunnycemetery@gmail.com + + 2/22 + ---- +bashline.c + - completion_glob_pattern: make sure to skip over a character quoted + by a backslash. Fixes bug reported by John Van Sickle + + + 2/23 + ---- +lib/readline/complete.c + - last_completion_failed: keep track of whether the last completion + attempt generated any matches + - rl_complete: if the last readline command was completion, but the + completion attempt didn't generate any matches, don't regenerate + and display the match list. Treat it as a new completion attempt. + Suggested by Richard Stallman + +bashhist.c + - maybe_append_history: try to handle the case where the number of + history entries in the current shell session is greater than the + number of entries in the history list. Based on a report from + diff --git a/MANIFEST b/MANIFEST index 5c9a37bbb..fea4c1a8c 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1249,6 +1249,7 @@ tests/quote.tests f tests/quote.right f tests/quote1.sub f tests/quote2.sub f +tests/quote3.sub f tests/read.tests f tests/read.right f tests/read1.sub f diff --git a/bashhist.c b/bashhist.c index f7f168ff2..710372b2e 100644 --- a/bashhist.c +++ b/bashhist.c @@ -436,11 +436,11 @@ int maybe_append_history (filename) char *filename; { - int fd, result; + int fd, result, histlen; struct stat buf; result = EXECUTION_SUCCESS; - if (history_lines_this_session > 0 && (history_lines_this_session <= where_history ())) + if (history_lines_this_session > 0) { /* If the filename was supplied, then create it if necessary. */ if (stat (filename, &buf) == -1 && errno == ENOENT) @@ -453,6 +453,10 @@ maybe_append_history (filename) } close (fd); } + /* cap the number of lines we write at the length of the history list */ + histlen = where_history (); + if (histlen > 0 && history_lines_this_session > histlen) + history_lines_this_session = histlen; /* reset below anyway */ result = append_history (history_lines_this_session, filename); /* Pretend we already read these lines from the file because we just added them */ diff --git a/bashline.c b/bashline.c index 34e2e34ad..0e2501714 100644 --- a/bashline.c +++ b/bashline.c @@ -3765,7 +3765,7 @@ completion_glob_pattern (string) continue; case '\\': - if (*string == 0) + if (*string++ == 0) return (0); } diff --git a/lib/readline/complete.c b/lib/readline/complete.c index adce0d69a..7da8ee98f 100644 --- a/lib/readline/complete.c +++ b/lib/readline/complete.c @@ -406,6 +406,7 @@ int rl_sort_completion_matches = 1; /* Local variable states what happened during the last completion attempt. */ static int completion_changed_buffer; +static int last_completion_failed = 0; /* The result of the query to the user about displaying completion matches */ static int completion_y_or_n; @@ -428,7 +429,7 @@ rl_complete (int ignore, int invoking_key) if (rl_inhibit_completion) return (_rl_insert_char (ignore, invoking_key)); - else if (rl_last_func == rl_complete && !completion_changed_buffer) + else if (rl_last_func == rl_complete && completion_changed_buffer == 0 && last_completion_failed == 0) return (rl_complete_internal ('?')); else if (_rl_complete_show_all) return (rl_complete_internal ('!')); @@ -477,7 +478,7 @@ rl_completion_mode (rl_command_func_t *cfunc) /* */ /************************************/ -/* Reset readline state on a signal or other event. */ +/* Reset public readline state on a signal or other event. */ void _rl_reset_completion_state (void) { @@ -2023,6 +2024,7 @@ rl_complete_internal (int what_to_do) rl_ding (); FREE (saved_line_buffer); completion_changed_buffer = 0; + last_completion_failed = 1; RL_UNSETSTATE(RL_STATE_COMPLETING); _rl_reset_completion_state (); return (0); @@ -2038,11 +2040,15 @@ rl_complete_internal (int what_to_do) rl_ding (); FREE (saved_line_buffer); completion_changed_buffer = 0; + last_completion_failed = 1; RL_UNSETSTATE(RL_STATE_COMPLETING); _rl_reset_completion_state (); return (0); } + if (matches && matches[0] && *matches[0]) + last_completion_failed = 0; + switch (what_to_do) { case TAB: diff --git a/tests/quote.right b/tests/quote.right index 174384aa1..cb291eb85 100644 --- a/tests/quote.right +++ b/tests/quote.right @@ -128,3 +128,17 @@ argv[2] = <> argv[1] = <> argv[2] = <> argv[1] = <> +argv[1] = <4> +argv[2] = <> +argv[1] = +argv[2] = <> +argv[1] = +argv[2] = <> +argv[1] = +argv[2] = <> +argv[1] = +argv[2] = <> +argv[1] = +argv[1] = +argv[1] = +argv[1] = diff --git a/tests/quote.tests b/tests/quote.tests index d7f13cd0c..402da2d59 100644 --- a/tests/quote.tests +++ b/tests/quote.tests @@ -122,3 +122,4 @@ echo ${foo:-string \\\}} ${THIS_SH} ./quote1.sub ${THIS_SH} ./quote2.sub +${THIS_SH} ./quote3.sub diff --git a/tests/quote3.sub b/tests/quote3.sub new file mode 100644 index 000000000..482286824 --- /dev/null +++ b/tests/quote3.sub @@ -0,0 +1,18 @@ +# new tests +x=4 +sp=' ' + +# word +recho ${x}${sp}'' + +# unquoted +recho ${x+ab "$y"} +recho ${x+ab ''} +recho ${x+ab "$( : )"} +recho ${x+ab "${yy}"} + +# quoted +recho "${x+ab ''}" +recho "${x+ab ""}" +recho "${x+ab '${yy}'}" +recho "${x+ab "${yy}"}"