use crate::{Shell, Simplified};
use std::path::Path;
pub fn shlex_posix(executable: impl AsRef<Path>) -> String {
let executable = executable.as_ref().portable_display().to_string();
if executable.contains(' ') {
format!("'{}'", escape_posix_for_single_quotes(&executable))
} else {
executable
}
}
pub fn escape_posix_for_single_quotes(string: &str) -> String {
string.replace('\'', r#"'"'"'"#)
}
pub fn shlex_windows(executable: impl AsRef<Path>, shell: Shell) -> String {
let executable = executable.as_ref().user_display().to_string();
if executable.contains(' ') {
if shell == Shell::Powershell {
format!("& \"{executable}\"")
} else {
format!("\"{executable}\"")
}
} else {
executable
}
}