pub async fn run_external_utility_in_subshell(
env: &mut Env,
path: CString,
args: Vec<Field>,
handle_start_subshell_error: fn(&mut Env, StartSubshellError) -> Pin<Box<dyn Future<Output = ()> + '_>>,
handle_replace_current_process_error: fn(&mut Env, ReplaceCurrentProcessError, Location) -> Pin<Box<dyn Future<Output = ()> + '_>>,
) -> Result<ExitStatus>Expand description
Starts an external utility in a subshell and waits for it to finish.
path is the path to the external utility. args are the command line
words of the utility. The first field must exist and be the name of the
utility as it may be used in error messages.
This function starts the utility in a subshell and waits for it to finish. The subshell will be a foreground job if job control is enabled.
This function returns the exit status of the utility. In case of an error,
one of the error handling functions will be called before returning an
appropriate exit status. handle_start_subshell_error is called in the
parent shell if starting the subshell fails.
handle_replace_current_process_error is called in the subshell if
replacing the subshell process with the utility fails. Both functions
should print appropriate error messages.
This function is for implementing the simple command execution semantics and
the command built-in utility. This function internally uses
replace_current_process to execute the utility in the subshell.