From e93bed95a81ae405ee5975bb13754a013f410fc0 Mon Sep 17 00:00:00 2001 From: Chet Ramey Date: Thu, 9 Dec 2021 15:31:21 -0500 Subject: [PATCH] fix for adding here-documents to history; change to checking for custom LS_COLORS prefix --- CWRU/CWRU.chlog | 15 +++++++++++++++ bashhist.c | 2 +- compatibility-level | 27 --------------------------- lib/readline/colors.c | 2 +- parse.y | 11 +++++++---- 5 files changed, 24 insertions(+), 33 deletions(-) delete mode 100644 compatibility-level diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 39a2af970..821e85c03 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -2607,3 +2607,18 @@ COMPAT,doc/bashref.texi lib/malloc/malloc.c - mremap: only use if MREMAP_MAYMOVE is defined, since we use the Linux version of the function signature + + 12/6 + ---- +bashhist.c + - bash_add_history: if we're parsing a here-document (PST_HEREDOC), only + suppress adding the newline between lines if we're not at the first + line of the here-document (here_doc_first_line!= 0). From a report + by S0AndS0 + + 12/8 + ---- +lib/readline/colors.c + - _rl_custom_readline_prefix: use STREQN to check for the extension + string in $LS_COLORS, since it's not necessarily null-terminated. + From https://savannah.gnu.org/patch/?10158 diff --git a/bashhist.c b/bashhist.c index 3ad417dfd..90cd8c34f 100644 --- a/bashhist.c +++ b/bashhist.c @@ -892,7 +892,7 @@ bash_add_history (line) (current_command_line_count > 2) don't add a newline here. This will also take care of the literal_history case if the other conditions are met. */ - if ((parser_state & PST_HEREDOC) && current_command_line_count > 2 && line[strlen (line) - 1] == '\n') + if ((parser_state & PST_HEREDOC) && here_doc_first_line == 0 && line[strlen (line) - 1] == '\n') chars_to_add = ""; else if (current_command_line_count == current_command_line_comment+1) chars_to_add = "\n"; diff --git a/compatibility-level b/compatibility-level deleted file mode 100644 index 8edd8d4d1..000000000 --- a/compatibility-level +++ /dev/null @@ -1,27 +0,0 @@ -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/lib/readline/colors.c b/lib/readline/colors.c index f7b9dfddc..dba81a279 100644 --- a/lib/readline/colors.c +++ b/lib/readline/colors.c @@ -120,7 +120,7 @@ _rl_custom_readline_prefix (void) len = strlen (RL_COLOR_PREFIX_EXTENSION); for (ext = _rl_color_ext_list; ext; ext = ext->next) - if (ext->ext.len == len && STREQ (ext->ext.string, RL_COLOR_PREFIX_EXTENSION)) + if (ext->ext.len == len && STREQN (ext->ext.string, RL_COLOR_PREFIX_EXTENSION, len)) return (&ext->seq); return (NULL); } diff --git a/parse.y b/parse.y index 990fcc469..fa70644d7 100644 --- a/parse.y +++ b/parse.y @@ -4064,10 +4064,13 @@ parse_comsub (qc, open, close, lenp, flags) /* Posix interp 217 says arithmetic expressions have precedence, so assume $(( introduces arithmetic expansion and parse accordingly. */ - peekc = shell_getc (0); - shell_ungetc (peekc); - if (peekc == '(') - return (parse_matched_pair (qc, open, close, lenp, 0)); + if (open == '(') /*)*/ + { + peekc = shell_getc (0); + shell_ungetc (peekc); + if (peekc == '(') /*)*/ + return (parse_matched_pair (qc, open, close, lenp, 0)); + } /*itrace("parse_comsub: qc = `%c' open = %c close = %c", qc, open, close);*/ -- 2.47.2