1 Star 0 Fork 38

zhaomengmeng/bash

forked from src-openEuler/bash 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-fix-for-E-transformation-fixes-for-failures-in-arith.patch 2.43 KB
一键复制 编辑 原始数据 按行查看 历史
wangyuhang 提交于 2024-04-26 17:15 . sync patches from bash community
From 09c32bc946baad7364b30abb491f72f7728b56d9 Mon Sep 17 00:00:00 2001
From: Chet Ramey <[email protected]>
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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mmzzmm/bash.git
[email protected]:mmzzmm/bash.git
mmzzmm
bash
bash
master

搜索帮助