修改echo和type命令报错

(cherry picked from commit 8917d0c452d2d0b92b372cdeb6cfad9450debbb5)
This commit is contained in:
wangmengc 2024-12-13 17:52:54 +08:00 committed by openeuler-sync-bot
parent 8de680d65b
commit 485f814f89
3 changed files with 82 additions and 1 deletions

36
0008-fix-echo-a.z.patch Normal file
View File

@ -0,0 +1,36 @@
From 35f29adb96c082cd94ec0c72c62556b4fde1e05c Mon Sep 17 00:00:00 2001
From: wangmengc <wangmengc@uniontech.com>
Date: Fri, 13 Dec 2024 17:15:50 +0800
Subject: [PATCH] fix echo {a..z}
---
r_braces/src/lib.rs | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/r_braces/src/lib.rs b/r_braces/src/lib.rs
index ee83ac1..d36ff1f 100644
--- a/r_braces/src/lib.rs
+++ b/r_braces/src/lib.rs
@@ -378,7 +378,7 @@ pub unsafe extern "C" fn brace_expand(
loop {
if *amble.offset(j as isize) as libc::c_int == 0 as libc::c_int {
tack = expand_seqterm (amble, alen);
- if tack.is_null() {
+ if !tack.is_null() {
break;
}
else if !text.offset((i+1) as isize).is_null() {
@@ -692,7 +692,9 @@ unsafe extern "C" fn expand_seqterm(
lhs = substring(text, 0 as libc::c_int, lhs_l);
rhs = substring(
text,
- (lhs_l + std::mem::size_of::<[libc::c_char; 3]> as libc::c_int - 1 as libc::c_int ),
+ (lhs_l as libc::c_ulong)
+ .wrapping_add(::std::mem::size_of::<[libc::c_char; 3]>() as libc::c_ulong)
+ .wrapping_sub(1 as libc::c_int as libc::c_ulong) as libc::c_int,
tlen as libc::c_int,
);
if *lhs.offset(0 as libc::c_int as isize) as libc::c_int == 0 as libc::c_int
--
2.39.3

View File

@ -0,0 +1,38 @@
From 7af7b30f2dc162ff4999a5c0e11132796f62b0be Mon Sep 17 00:00:00 2001
From: wangmengc <wangmengc@uniontech.com>
Date: Fri, 13 Dec 2024 17:35:33 +0800
Subject: [PATCH] fix type return error
---
builtins_rust/type/src/lib.rs | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/builtins_rust/type/src/lib.rs b/builtins_rust/type/src/lib.rs
index 4940fae..c1b470e 100644
--- a/builtins_rust/type/src/lib.rs
+++ b/builtins_rust/type/src/lib.rs
@@ -555,17 +555,16 @@ pub unsafe extern "C" fn r_type_builtin(mut list: *mut WordList) -> i32 {
sh_notfound((*(*list).word).word);
}
}
- any_failed = found + any_failed;
- let _ = any_failed == 0;
- // (any_failed += found) == 0;
+
+ any_failed += (found == 0 as libc::c_int) as libc::c_int;
unsafe {
list = (*list).next;
}
}
if any_failed == 0 {
- EXECUTION_SUCCESS!();
+ opt = EXECUTION_SUCCESS!();
} else {
- EXECUTION_FAILURE!();
+ opt = EXECUTION_FAILURE!();
}
return unsafe { sh_chkwrite(opt) };
}
--
2.39.3

View File

@ -6,7 +6,7 @@
Version: %{baseversion}%{patchleveltag}
Name: utshell
Summary: The utshell respect Bash
Release: 1%{?dist}
Release: 1%{?dist}.01
License: GPLv3+
Source0: utshell-%{baseversion}.tar.gz
@ -19,6 +19,8 @@ Patch0004: 0004-fix-complete-p-no-display.patch
Patch0005: 0005-fix-translation-files-correlation.patch
Patch0006: 0006-fix-select-error.patch
Patch0007: 0007-fix-compile-error-on-riscv64.patch
Patch0008: 0008-fix-echo-a.z.patch
Patch0009: 0009-fix-type-return-error.patch
# Other patches
# We don't want to add '/etc:/usr/etc' in standard utils path.
@ -135,6 +137,11 @@ end
%{_includedir}/%{name}
%changelog
* Fri Dec 13 2024 wangmeng <wangmengc@uniontech.com> - 0.5.1-0.1
- feat: add patch 0003-fix-echo-a.z.patch
- feat: add patch 0004-fix-type-return-error.patch
- 修复echo {a..z} 执行错误和type命令返回值错误
* Fri Jun 21 2024 wangmeng<wangmengc@uniontech.con> - 0.5.1
- fix:IA4DBK Change the verson number to be consistent with other software packages