Skip to content

Commit cbad2e9

Browse files
Fix support for shadowenv exec -- echo foo
1 parent d24c941 commit cbad2e9

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub struct ExecCmd {
2121
pub dir: Option<String>,
2222

2323
/// The command to execute.
24-
pub cmd: String,
24+
pub cmd_argv0: Option<String>,
2525

2626
/// The arguments to the command, if any.
2727
#[arg(last = true)]

src/exec_cmd.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,13 @@ pub fn run(cmd: ExecCmd) -> Result<(), Error> {
1414
hook::mutate_own_env(&shadowenv)?;
1515
}
1616

17-
let argv = iter::once(cmd.cmd).chain(cmd.cmd_argv).collect::<Vec<_>>();
17+
let argv = if let Some(argv0) = cmd.cmd_argv0 {
18+
iter::once(argv0).chain(cmd.cmd_argv).collect::<Vec<_>>()
19+
} else if !cmd.cmd_argv.is_empty() {
20+
cmd.cmd_argv
21+
} else {
22+
return Err(anyhow::anyhow!("no command provided"));
23+
};
1824

1925
// exec only returns if it was unable to start the new process, and it's always an error.
2026
let err = exec::Command::new(&argv[0]).args(&argv[1..]).exec();

0 commit comments

Comments
 (0)