BASH PATCH REPORT
                            =================

Bash-Release:   5.2
Patch-ID:       bash52-029

Bug-Reported-by:        Grisha Levit <[email protected]>
Bug-Reference-ID:       <CAMu=Brp9QHvLh8vbY45hRgCVaQUNSnU7n8EVjsWKajT7c99K8Q@mail.gmail.com>
Bug-Reference-URL:      https://lists.gnu.org/archive/html/bug-bash/2023-04/msg00072.html

Bug-Description:

There are problems with recovery after parser errors when parsing compound
assignments. For instance, the `local' builtin reports an error but never
cleans up the function context.

Patch (apply with `patch -p0'):

*** ../bash-20230427/parse.y    Fri Apr 14 11:50:29 2023
--- parse.y     Mon May  1 16:25:14 2023
***************
*** 6471,6478 ****
     {
       set_exit_status (EXECUTION_FAILURE);
       if (interactive_shell == 0 && posixly_correct)
       jump_to_top_level (FORCE_EOF);
       else
!       jump_to_top_level (DISCARD);
     }

--- 6471,6483 ----
     {
       set_exit_status (EXECUTION_FAILURE);
+       current_token = '\n';   /* XXX */
       if (interactive_shell == 0 && posixly_correct)
       jump_to_top_level (FORCE_EOF);
       else
!       {
!         if (executing && parse_and_execute_level == 0)
!           top_level_cleanup ();
!         jump_to_top_level (DISCARD);
!       }
     }

***************
*** 6538,6546 ****
     {
       set_exit_status (EXECUTION_FAILURE);
!       last_read_token = '\n'; /* XXX */
       if (interactive_shell == 0 && posixly_correct)
       jump_to_top_level (FORCE_EOF);
       else
!       jump_to_top_level (DISCARD);
     }

--- 6543,6555 ----
     {
       set_exit_status (EXECUTION_FAILURE);
!       last_read_token = current_token = '\n'; /* XXX */
       if (interactive_shell == 0 && posixly_correct)
       jump_to_top_level (FORCE_EOF);
       else
!       {
!         if (executing && parse_and_execute_level == 0)
!           top_level_cleanup ();
!         jump_to_top_level (DISCARD);
!       }
     }


*** ../bash-20230427/y.tab.c    Tue Jul 30 15:19:31 2024
--- y.tab.c     Tue Jul 30 15:20:21 2024
***************
*** 8786,8793 ****
     {
       set_exit_status (EXECUTION_FAILURE);
       if (interactive_shell == 0 && posixly_correct)
       jump_to_top_level (FORCE_EOF);
       else
!       jump_to_top_level (DISCARD);
     }

--- 8786,8798 ----
     {
       set_exit_status (EXECUTION_FAILURE);
+       current_token = '\n';   /* XXX */
       if (interactive_shell == 0 && posixly_correct)
       jump_to_top_level (FORCE_EOF);
       else
!       {
!         if (executing && parse_and_execute_level == 0)
!           top_level_cleanup ();
!         jump_to_top_level (DISCARD);
!       }
     }

***************
*** 8853,8861 ****
     {
       set_exit_status (EXECUTION_FAILURE);
!       last_read_token = '\n'; /* XXX */
       if (interactive_shell == 0 && posixly_correct)
       jump_to_top_level (FORCE_EOF);
       else
!       jump_to_top_level (DISCARD);
     }

--- 8858,8870 ----
     {
       set_exit_status (EXECUTION_FAILURE);
!       last_read_token = current_token = '\n'; /* XXX */
       if (interactive_shell == 0 && posixly_correct)
       jump_to_top_level (FORCE_EOF);
       else
!       {
!         if (executing && parse_and_execute_level == 0)
!           top_level_cleanup ();
!         jump_to_top_level (DISCARD);
!       }
     }


*** ../bash-5.2/patchlevel.h    2020-06-22 14:51:03.000000000 -0400
--- patchlevel.h        2020-10-01 11:01:28.000000000 -0400
***************
*** 26,30 ****
    looks for to find the patch level (for the sccs version string). */

! #define PATCHLEVEL 28

 #endif /* _PATCHLEVEL_H_ */
--- 26,30 ----
    looks for to find the patch level (for the sccs version string). */

! #define PATCHLEVEL 29

 #endif /* _PATCHLEVEL_H_ */