File tree 2 files changed +8
-2
lines changed
2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ pub struct ExecCmd {
21
21
pub dir : Option < String > ,
22
22
23
23
/// The command to execute.
24
- pub cmd : String ,
24
+ pub cmd_argv0 : Option < String > ,
25
25
26
26
/// The arguments to the command, if any.
27
27
#[ arg( last = true ) ]
Original file line number Diff line number Diff line change @@ -14,7 +14,13 @@ pub fn run(cmd: ExecCmd) -> Result<(), Error> {
14
14
hook:: mutate_own_env ( & shadowenv) ?;
15
15
}
16
16
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
+ } ;
18
24
19
25
// exec only returns if it was unable to start the new process, and it's always an error.
20
26
let err = exec:: Command :: new ( & argv[ 0 ] ) . args ( & argv[ 1 ..] ) . exec ( ) ;
You can’t perform that action at this time.
0 commit comments