]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
Bash-5.2 patch 29: fix for error recovery when parsing invalid compound assignments
authorChet Ramey <chet.ramey@case.edu>
Thu, 1 Aug 2024 15:34:42 +0000 (11:34 -0400)
committerChet Ramey <chet.ramey@case.edu>
Thu, 1 Aug 2024 15:34:42 +0000 (11:34 -0400)
parse.y
patchlevel.h
y.tab.c

diff --git a/parse.y b/parse.y
index 8fd24a1c79803b6bb99d55bc123479fb8c080da6..78b49175a2bbf7e75729acf5ffaf50f6bc26e1c6 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -6470,10 +6470,15 @@ parse_string_to_word_list (s, flags, whom)
   if (wl == &parse_string_error)
     {
       set_exit_status (EXECUTION_FAILURE);
+      current_token = '\n';    /* XXX */
       if (interactive_shell == 0 && posixly_correct)
        jump_to_top_level (FORCE_EOF);
       else
-       jump_to_top_level (DISCARD);
+       {
+         if (executing && parse_and_execute_level == 0)
+           top_level_cleanup ();
+         jump_to_top_level (DISCARD);
+       }
     }
 
   return (REVERSE_LIST (wl, WORD_LIST *));
@@ -6537,11 +6542,15 @@ parse_compound_assignment (retlenp)
   if (wl == &parse_string_error)
     {
       set_exit_status (EXECUTION_FAILURE);
-      last_read_token = '\n';  /* XXX */
+      last_read_token = current_token = '\n';  /* XXX */
       if (interactive_shell == 0 && posixly_correct)
        jump_to_top_level (FORCE_EOF);
       else
-       jump_to_top_level (DISCARD);
+       {
+         if (executing && parse_and_execute_level == 0)
+           top_level_cleanup ();
+         jump_to_top_level (DISCARD);
+       }
     }
 
   if (wl)
index 7abb1edb666997635fb2172a855f4d18afa2c383..386e1197b00d4e9bebf152f4d6d8928aaee2b6ad 100644 (file)
@@ -25,6 +25,6 @@
    regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
    looks for to find the patch level (for the sccs version string). */
 
-#define PATCHLEVEL 28
+#define PATCHLEVEL 29
 
 #endif /* _PATCHLEVEL_H_ */
diff --git a/y.tab.c b/y.tab.c
index 78c793065928f2d93ff63f72c89ef703788d28c2..793686e78544bd45457aaf4bc7a192c235d08a83 100644 (file)
--- a/y.tab.c
+++ b/y.tab.c
@@ -8785,10 +8785,15 @@ parse_string_to_word_list (s, flags, whom)
   if (wl == &parse_string_error)
     {
       set_exit_status (EXECUTION_FAILURE);
+      current_token = '\n';    /* XXX */
       if (interactive_shell == 0 && posixly_correct)
        jump_to_top_level (FORCE_EOF);
       else
-       jump_to_top_level (DISCARD);
+       {
+         if (executing && parse_and_execute_level == 0)
+           top_level_cleanup ();
+         jump_to_top_level (DISCARD);
+       }
     }
 
   return (REVERSE_LIST (wl, WORD_LIST *));
@@ -8852,11 +8857,15 @@ parse_compound_assignment (retlenp)
   if (wl == &parse_string_error)
     {
       set_exit_status (EXECUTION_FAILURE);
-      last_read_token = '\n';  /* XXX */
+      last_read_token = current_token = '\n';  /* XXX */
       if (interactive_shell == 0 && posixly_correct)
        jump_to_top_level (FORCE_EOF);
       else
-       jump_to_top_level (DISCARD);
+       {
+         if (executing && parse_and_execute_level == 0)
+           top_level_cleanup ();
+         jump_to_top_level (DISCARD);
+       }
     }
 
   if (wl)