pub fn execute_command(
command_text: &str,
cwd: Option<&Path>,
) -> Result<ExecutionResult>Expand description
Execute a command string through the shell.
Uses the SHELL environment variable (fallback /bin/sh) to run
the command via sh -c. Stdin, stdout, and stderr are inherited so
the user sees output in real-time and can interact with prompts.
If cwd is provided and the directory exists, the command runs in
that directory. If the directory doesn’t exist, a warning is printed
to stderr and the current directory is used instead.
For simple cd <path> commands, returns the resolved new directory
in ExecutionResult::new_cwd so the caller can update its working
directory for subsequent commands.
§Errors
Returns an error if the shell process cannot be spawned or waited on.