pub(crate) fn shell_single_quote(s: &str) -> String {
format!("'{}'", s.replace('\'', "'\\''"))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn quotes_plain_path() {
assert_eq!(
shell_single_quote("/opt/bin/pixtuoid-hook"),
"'/opt/bin/pixtuoid-hook'"
);
}
#[test]
fn quotes_path_with_spaces() {
assert_eq!(
shell_single_quote("/Users/Jane Doe/bin/pixtuoid-hook"),
"'/Users/Jane Doe/bin/pixtuoid-hook'"
);
}
#[test]
fn escapes_embedded_single_quote() {
assert_eq!(shell_single_quote("a'b"), r#"'a'\''b'"#);
}
}