From 09c32bc946baad7364b30abb491f72f7728b56d9 Mon Sep 17 00:00:00 2001
From: Chet Ramey <chet.ramey@case.edu>
Date: Tue, 10 Oct 2023 12:00:19 -0400
Subject: [PATCH] fix for @E transformation; fixes for failures in arith for
 and for commands; style changes to man page; fix for bug in read builtin if
 it assigns to IFS

Conflict:partial round, only the modified content of execute_cmd.c is rounded.
Reference:https://git.savannah.gnu.org/cgit/bash.git/commit/?id=09c32bc946baad7364b30abb491f72f7728b56d9
---
 execute_cmd.c | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/execute_cmd.c b/execute_cmd.c
index a855376..71d147c 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -2837,8 +2837,11 @@ execute_for_command (for_command)
 #endif
 
   save_line_number = line_number;
+  line_number = for_command->line;	/* for expansion error messages */
+
   if (check_identifier (for_command->name, 1) == 0)
     {
+      line_number = save_line_number;
       if (posixly_correct && interactive_shell == 0)
 	{
 	  last_command_exit_value = EX_BADUSAGE;
@@ -2850,7 +2853,6 @@ execute_for_command (for_command)
   loop_level++;
   identifier = for_command->name->word;
 
-  line_number = for_command->line;	/* for expansion error messages */
   list = releaser = expand_words_no_vars (for_command->map_list);
 
   begin_unwind_frame ("for");
@@ -3075,13 +3077,8 @@ execute_arith_for_command (arith_for_command)
 
   /* Evaluate the initialization expression. */
   expresult = eval_arith_for_expr (arith_for_command->init, &expok);
-  if (expok == 0)
-    {
-      line_number = save_lineno;
-      return (EXECUTION_FAILURE);
-    }
 
-  while (1)
+  while (expok)
     {
       /* Evaluate the test expression. */
       line_number = arith_lineno;
@@ -3089,10 +3086,8 @@ execute_arith_for_command (arith_for_command)
       line_number = save_lineno;
 
       if (expok == 0)
-	{
-	  body_status = EXECUTION_FAILURE;
-	  break;
-	}
+	break;
+
       REAP ();
       if (expresult == 0)
 	break;
@@ -3120,18 +3115,12 @@ execute_arith_for_command (arith_for_command)
       line_number = arith_lineno;
       expresult = eval_arith_for_expr (arith_for_command->step, &expok);
       line_number = save_lineno;
-
-      if (expok == 0)
-	{
-	  body_status = EXECUTION_FAILURE;
-	  break;
-	}
     }
 
   loop_level--;
   line_number = save_lineno;
 
-  return (body_status);
+  return (expok ? body_status : EXECUTION_FAILURE);
 }
 #endif
 
-- 
2.33.0

