$ 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