Skip to main content

shell_command

Function shell_command 

Source
pub fn shell_command() -> (String, String)
Available on crate feature terminal only.
Expand description

Returns the platform’s shell binary plus its “run this command string” flag, honouring $SHELL (Unix) / %COMSPEC% (Windows) where set — the portable seam behind Command::new(shell).arg(flag).arg(command).

Sibling of default_shell: default_shell() names a shell for an interactive PTY session (used by TerminalSession::spawn); shell_command() is for launching a single command string through “the user’s shell” — the case vimcode’s :!, :r !, !{motion} filters, and plugin async shells all hardcode as Command::new("sh") today, with no Windows leg. default_shell()’s own behaviour is unchanged by this function’s addition.

Falls back to ("sh", "-c") on Unix and ("cmd", "/C") on Windows when the relevant environment variable isn’t set. Both fallbacks are resolved via PATH by the process spawner (std::process::Command / portable_pty::CommandBuilder), not by an absolute path, matching core/lsp_manager.rs’s existing cmd /C vs sh -c split in vimcode.

§Example

use quadraui::terminal_engine::shell_command;

let (shell, flag) = shell_command();
let mut cmd = std::process::Command::new(shell);
cmd.arg(flag).arg("echo hello");