mirror of
https://github.com/starship/starship.git
synced 2025-03-12 05:59:17 +01:00
add handling for cmd custom commands
This commit is contained in:
parent
2d4d588c3d
commit
f68e8f118f
@ -161,6 +161,7 @@ fn shell_command(cmd: &str, shell_args: &[&str]) -> Option<Output> {
|
||||
.stderr(Stdio::piped());
|
||||
|
||||
handle_powershell(&mut command, &forced_shell, shell_args);
|
||||
handle_cmd(&mut command, &forced_shell, shell_args);
|
||||
|
||||
if let Ok(mut child) = command.spawn() {
|
||||
child.stdin.as_mut()?.write_all(cmd.as_bytes()).ok()?;
|
||||
@ -247,6 +248,15 @@ fn handle_powershell(command: &mut Command, shell: &str, shell_args: &[&str]) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn handle_cmd(command: &mut Command, shell: &str, shell_args: &[&str]) {
|
||||
let is_cmd = shell.ends_with("cmd.exe") || shell.ends_with("cmd");
|
||||
|
||||
if is_cmd && shell_args.is_empty() {
|
||||
command.arg("/C");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
Loading…
Reference in New Issue
Block a user