Skip to content

Commit 2734d90

Browse files
committed
feat: 修改 shell_run_cmd 方法以支持直接执行命令字符串,简化命令参数处理
1 parent 916024d commit 2734d90

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

ostool/src/ctx.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ pub struct AppContext {
2222

2323
impl AppContext {
2424
pub fn shell_run_cmd(&self, cmd: &str) -> anyhow::Result<()> {
25-
let mut parts = cmd.split_whitespace();
26-
let mut command = self.command(parts.next().unwrap());
27-
for arg in parts {
28-
command.arg(arg);
29-
}
25+
let mut command = self.command("sh");
26+
command.arg("-c");
27+
command.arg(cmd);
28+
3029
if let Some(elf) = &self.elf_path {
3130
command.env("KERNEL_ELF", elf.display().to_string());
3231
}

ostool/src/run/uboot.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ impl Runner {
272272
if let Some(ref cmd) = self.config.board_power_off_cmd
273273
&& !cmd.trim().is_empty()
274274
{
275-
info!("Executing board power off command: {}", cmd);
276275
let _ = self.ctx.shell_run_cmd(cmd);
277276
info!("Board powered off");
278277
}
@@ -318,7 +317,6 @@ impl Runner {
318317
if let Some(cmd) = self.config.board_reset_cmd.clone()
319318
&& !cmd.trim().is_empty()
320319
{
321-
info!("Executing board reset command: {}", cmd);
322320
self.ctx.shell_run_cmd(&cmd)?;
323321
}
324322

0 commit comments

Comments
 (0)