]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
fix issue with reserved words in case clauses in command substitution; fix issue...
authorChet Ramey <chet.ramey@case.edu>
Tue, 9 Jan 2024 21:00:15 +0000 (16:00 -0500)
committerChet Ramey <chet.ramey@case.edu>
Tue, 9 Jan 2024 21:00:15 +0000 (16:00 -0500)
CWRU/CWRU.chlog
Makefile.in
lib/readline/doc/readline.3
lib/readline/doc/rltech.texi
lib/readline/doc/version.texi
parse.y
po/zh_CN.gmo
po/zh_CN.po
print_cmd.c

index c32d4ba31f1434d97c8cab2a8b479ba7b0879393..6fd26ca01cfa30fb4101fc69be6cf48d8d81ddb3 100644 (file)
@@ -8235,3 +8235,28 @@ shell.c
        - execute_bashrc_file: execute whatever find_bashrc_file() returns
          if bashrc_file is NULL
          From a patch from Allison Karlitskaya <allison.karlitskaya@redhat.com>
+
+                                1/3/2024
+                                --------
+print_cmd.c
+       - print_case_clauses: if we're printing a comsub for subsequent parsing,
+         don't add a newline before the first case clause, since it adds a
+         token after the `in' that will allow reserved words to be parsed.
+         Report from Oguz <oguzismailuysal@gmail.com>
+
+                                   1/5
+                                   ---
+lib/readline/doc/rltech.texi,lib/readline/doc/readline.3
+       - Note that since quoted characters are possible, the line readline()
+         returns may contain embedded newlines.
+         From a report by Martin Buck <mb-tmp-tah.bet@gromit.dyndns.org>
+
+                                   1/8
+                                   ---
+parse.y
+       - parse_compound_assignment,parse_string_to_word_list: if we call
+         reset_parser, directly or indirectly via yyerror, make sure to set
+         the pushed_strings member of the saved parser state to NULL, since
+         reset_parser already freed it and we don't want to try and restore
+         it in restore_parser_state.
+         From a report by Nathan Mills <the.true.nathan.mills@gmail.com>
index d6fdd70b2938ecd94a11933e088c833fb3511940..b52069e1f41a2a78a33f657141685158f85b67b4 100644 (file)
@@ -172,6 +172,11 @@ UBSAN_XLDFLAGS = -fsanitize=undefined
 GCOV_XCFLAGS = -fprofile-arcs -ftest-coverage
 GCOV_XLDFLAGS = -fprofile-arcs -ftest-coverage
 
+# these need CC=clang
+LSAN_CC = clang
+LSAN_XCFLAGS = -fsanitize=leak -fno-common -fno-omit-frame-pointer -fno-optimize-sibling-calls
+LSAN_XLDFLAGS = -fsanitize=leak
+
 INCLUDES = -I. @RL_INCLUDE@ -I$(srcdir) -I$(BASHINCDIR) -I$(LIBSRC) $(INTL_INC)
 
 # Maybe add: -Wextra
@@ -634,10 +639,14 @@ ubsan:
 valgrind:
        ${MAKE} ${MFLAGS} ADDON_CFLAGS='-DDISABLE_MALLOC_WRAPPERS' ADDON_LDFLAGS= .made
 
+lsan:
+       ${MAKE} ${MFLAGS} CC=${LSAN_CC} ADDON_CFLAGS='${LSAN_XCFLAGS}' ADDON_LDFLAGS='${LSAN_XLDFLAGS}' .made
+
 # cheating
 gcov:
        ${MAKE} ${MFLAGS} CFLAGS=-g ADDON_CFLAGS='${GCOV_XCFLAGS}' ADDON_LDFLAGS='${GCOV_XLDFLAGS}' .made
 
+
 # have to make this separate because making tests depend on $(PROGRAM)
 asan-tests: asan  $(TESTS_SUPPORT)
        @-test -d tests || mkdir tests
@@ -645,6 +654,13 @@ asan-tests: asan  $(TESTS_SUPPORT)
        @( cd $(srcdir)/tests && \
                BUILD_DIR=$(BUILD_DIR) PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
 
+# have to make this separate because making tests depend on $(PROGRAM)
+lsan-tests: lsan  $(TESTS_SUPPORT)
+       @-test -d tests || mkdir tests
+       @cp $(TESTS_SUPPORT) tests
+       @( cd $(srcdir)/tests && \
+               BUILD_DIR=$(BUILD_DIR) PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
+
 profiling-tests:       ${PROGRAM}
        @test "X$$PROFILE_FLAGS" == "X" && { echo "profiling-tests: must be built with profiling enabled" >&2; exit 1; }
        @${MAKE} ${MFLAGS} tests TESTSCRIPT=run-gprof
index 9977ad30fa90fd026aae48fee1b3696ceffbb019..9af32f7ba2d7e0b95e98ba76b4f0273146f82628 100644 (file)
@@ -6,9 +6,9 @@
 .\"    Case Western Reserve University
 .\"    chet.ramey@case.edu
 .\"
-.\"    Last Change: Thu Dec 21 09:29:52 EST 2023
+.\"    Last Change: Fri Jan  5 11:02:00 EST 2024
 .\"
-.TH READLINE 3 "2023 December 21" "GNU Readline 8.3"
+.TH READLINE 3 "2024 January 5" "GNU Readline 8.3"
 .\"
 .\" File Name macro.  This used to be `.PN', for Path Name,
 .\" but Sun doesn't seem to like that very much.
@@ -34,8 +34,8 @@ readline \- get a line from a user with editing
 \fBreadline\fP (\fIconst char *prompt\fP);
 .fi
 .SH COPYRIGHT
-.if n Readline is Copyright (C) 1989\-2023 Free Software Foundation,  Inc.
-.if t Readline is Copyright \(co 1989\-2023 Free Software Foundation, Inc.
+.if n Readline is Copyright (C) 1989\-2024 Free Software Foundation,  Inc.
+.if t Readline is Copyright \(co 1989\-2024 Free Software Foundation, Inc.
 .SH DESCRIPTION
 .LP
 .B readline
@@ -50,6 +50,9 @@ The line returned is allocated with
 the caller must free it when finished.  The line returned
 has the final newline removed, so only the text of the line
 remains.
+Since it's possible to enter characters into the line while quoting
+them to disable any \fBreadline\fP editing function they might normally have,
+this line may include embedded newlines and other special characters.
 .LP
 .B readline
 offers editing capabilities while the user is entering the
index 8b9bd8c06a1f8875542781f00aef3aa643209151..54f68af90ab69ca866c241997eae524c70585fa2 100644 (file)
@@ -67,6 +67,9 @@ the simplest way possible, perhaps to replace calls in your code to
 
 The function @code{readline()} prints a prompt @var{prompt}
 and then reads and returns a single line of text from the user.
+Since it's possible to enter characters into the line while quoting
+them to disable any Readline editing function they might normally have,
+this line may include embedded newlines and other special characters.
 If @var{prompt} is @code{NULL} or the empty string, no prompt is displayed.
 The line @code{readline} returns is allocated with @code{malloc()};
 the caller should @code{free()} the line when it has finished with it.
index 57ff52c1fb058f0a2310fc186b72c5939e4ae69b..2eed8b11ded2e410a204c389fca3a850ff37a63f 100644 (file)
@@ -1,11 +1,11 @@
 @ignore
-Copyright (C) 1988-2023 Free Software Foundation, Inc. 
+Copyright (C) 1988-2024 Free Software Foundation, Inc. 
 @end ignore
 
 @set EDITION 8.3
 @set VERSION 8.3
 
-@set UPDATED 14 December 2023
-@set UPDATED-MONTH December 2023
+@set UPDATED 5 January 2024
+@set UPDATED-MONTH January 2024
 
-@set LASTCHANGE Thu Dec 14 15:45:46 EST 2023
+@set LASTCHANGE Fri Jan  5 11:01:44 EST 2024
diff --git a/parse.y b/parse.y
index b92eb5807b4a90a3eea64c5ec16bec467964ef22..dbc3fe6d897ef859827f206063ad904532234c4e 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -6894,6 +6894,7 @@ parse_string_to_word_list (char *s, int flags, const char *whom)
          orig_current_token = current_token;
          current_token = tok;
          yyerror (NULL);       /* does the right thing */
+         ps.pushed_strings = NULL;     /* freed by reset_parser */
          current_token = orig_current_token;
          if (wl)
            dispose_words (wl);
@@ -6980,8 +6981,12 @@ parse_compound_assignment (size_t *retlenp)
          current_token = tok;  /* for error reporting */
          if (tok == yacc_EOF)  /* ( */
            parser_error (orig_line_number, _("unexpected EOF while looking for matching `)'"));
+           /* XXX - reset_parser here, even at EOF? */
          else
-           yyerror(NULL);      /* does the right thing */
+           {
+             yyerror(NULL);    /* does the right thing */
+             ps.pushed_strings = NULL;         /* freed by reset_parser */
+           }
          if (wl)
            dispose_words (wl);
          wl = &parse_string_error;
index e3171aefc5079f3bf9c1c4030a40f2366f195a21..a184a2c6211d7ac93da4adaa5aa3ccd2e81a9f1c 100644 (file)
Binary files a/po/zh_CN.gmo and b/po/zh_CN.gmo differ
index 1869a358df0c33857b300eebab72aff7fb888055..3096bbfe48383ed946905592db263505929b09ee 100644 (file)
@@ -9,7 +9,7 @@
 # liushuyu <liushuyu011@gmail.com>, 2016.
 # Mingye Wang <arthur200126@gmail.com>, 2015, 2016.
 # Boyuan Yang <073plan@gmail.com>, 2018, 2019, 2020.
-# Wenbin Lv <wenbin816@gmail.com>, 2021, 2022.
+# Wenbin Lv <wenbin816@gmail.com>, 2021, 2022, 2024.
 #
 # 本翻译目前采用的格式约定,和其他注意事项:
 #
@@ -26,7 +26,7 @@ msgstr ""
 "Project-Id-Version: bash 5.2-rc1\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2022-01-11 14:50-0500\n"
-"PO-Revision-Date: 2022-06-18 14:25+0800\n"
+"PO-Revision-Date: 2024-01-09 22:43+0800\n"
 "Last-Translator: Wenbin Lv <wenbin816@gmail.com>\n"
 "Language-Team: Chinese (simplified) <i18n-zh@googlegroups.com>\n"
 "Language: zh_CN\n"
@@ -171,7 +171,7 @@ msgstr ""
 "    \n"
 "    不带有 <表达式> 时,返回 \"$line $filename\"。带有 <表达式> 时,\n"
 "    返回 \"$line $subroutine $filename\";这个额外的信息可以用来提供\n"
-"    æ \88è·\9f踪 (stack trace)。\n"
+"    æ \88追踪 (stack trace)。\n"
 "    \n"
 "    <表达式> 的值表示从当前调用帧需要回去多少个调用帧;栈顶帧是第 0 帧。"
 
@@ -1814,7 +1814,7 @@ msgstr "非法指令"
 
 #: siglist.c:67
 msgid "BPT trace/trap"
-msgstr "æ\96­ç\82¹è·\9f踪或陷阱"
+msgstr "æ\96­ç\82¹è¿½踪或陷阱"
 
 #: siglist.c:75
 msgid "ABORT instruction"
@@ -2190,7 +2190,7 @@ msgstr "%s: %s: 无法作为 FILE 打开"
 #: variables.c:6405
 #, c-format
 msgid "%s: %s: invalid value for trace file descriptor"
-msgstr "%s: %s: è·\9f踪文件描述符的值无效"
+msgstr "%s: %s: è¿½踪文件描述符的值无效"
 
 #: variables.c:6450
 #, c-format
@@ -2725,7 +2725,7 @@ msgstr ""
 "    \n"
 "    不带有 <表达式> 时,返回 \"$line $filename\"。带有 <表达式> 时,\n"
 "    返回 \"$line $subroutine $filename\";这个额外的信息可以用来提供\n"
-"    æ \88è·\9f踪 (stack trace)。\n"
+"    æ \88追踪 (stack trace)。\n"
 "    \n"
 "    <表达式> 的值表示从当前调用帧需要回去多少个调用帧;栈顶帧是第 0 帧。\n"
 "    \n"
@@ -2949,7 +2949,7 @@ msgstr ""
 "      -l\t将 <名称> 的值在赋值时转换为小写\n"
 "      -n\t使 <名称> 成为一个对以它的值为名称的变量的引用\n"
 "      -r\t将 <名称> 变为只读\n"
-"      -t\t使 <å\90\8dç§°> å¸¦æ\9c\89 \"è·\9f踪\" (trace) 属性\n"
+"      -t\t使 <å\90\8dç§°> å¸¦æ\9c\89 \"追踪\" (trace) 属性\n"
 "      -u\t使 <名称> 的值在赋值时转换为大写\n"
 "      -x\t将 <名称> 导出\n"
 "    \n"
@@ -3126,7 +3126,7 @@ msgstr ""
 "      -s\t仅打印 Posix \"特殊\" 内建的名称\n"
 "    \n"
 "    控制动态加载的选项:\n"
-"      -f\t从共享对象 <文件名> 中加载 <名称> 内建\n"
+"      -f\t从共享目标 <文件名> 中加载 <名称> 内建\n"
 "      -d\t删除以 -f 选项加载的内建\n"
 "    \n"
 "    不带选项时,启用每一个 <名称>。\n"
index 201824eab1fc1c6c58eeb945bbe4d92de1edc6b9..0886b5c2c9bbd5977bc43acd54a0fbf9003b2ff7 100644 (file)
@@ -759,10 +759,18 @@ print_case_command (CASE_COM *case_command)
 static void
 print_case_clauses (PATTERN_LIST *clauses)
 {
+  int first = 1;
+
   indentation += indentation_amount;
   while (clauses)
     {
-      newline ("");
+      /* If we're printing a comsub, the result will be reparsed later, so
+        we don't want to insert a newline after the `in': that could cause
+        the parser to parse a reserved word in error, since the newline
+        inserts a token after the `in'. */
+      if (printing_comsub == 0 || first == 0)
+       newline ("");
+      first = 0;
       command_print_word_list (clauses->patterns, " | ");
       cprintf (")\n");
       indentation += indentation_amount;