bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] fix for command invalid identifier line number


From: Grisha Levit
Subject: [PATCH] fix for command invalid identifier line number
Date: Tue, 26 Sep 2023 18:28:52 -0400

$ bash -u <<<$'for x in $1\ndo :\ndone'
bash: line 1: $1: unbound variable

$ bash -u <<<$'for 1 in $_\ndo :\ndone'
bash: line 3: `1': not a valid identifier
---
 execute_cmd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/execute_cmd.c b/execute_cmd.c
index 73723db5..9fba2b4f 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -2912,8 +2912,11 @@ execute_for_command (FOR_COM *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;
@@ -2925,7 +2928,6 @@ execute_for_command (FOR_COM *for_command)
   loop_level++; interrupt_execution++; retain_fifos++;
   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");
-- 
2.42.0



reply via email to

[Prev in Thread] Current Thread [Next in Thread]