Skip to main content

shell_command

Function shell_command 

Source
pub fn shell_command(command: &str) -> Command
Expand description

Build the platform shell invocation for a user-typed shell-out command — the one builder every shell-out site uses, so they all run the same shell. Callers still check shell_disabled first.

Unix runs sh -c <command>. Windows runs %COMSPEC% /S /C "<command>" (cmd.exe when COMSPEC is unset), vim’s shell / shellcmdflag / shellxquote defaults there: there is no sh on a stock Windows PATH. The command goes to cmd.exe as one raw, quote-wrapped argument, and /S makes cmd.exe strip exactly those outer quotes and run the rest verbatim. std’s default argument escaping would backslash-escape inner quotes, which cmd.exe does not understand — echo "a b" printed \"a b\" and a quoted program path failed to run.