pub fn quote_posix(value: &str) -> StringExpand description
Quote a value for sh, bash, zsh and direnv.
A POSIX single-quoted string ends at the first ' and interprets nothing inside it, so
a value is safe once every ' is closed, escaped outside the quotes, and reopened.
use majordomus_cli::environment::shell::quote_posix;
assert_eq!(quote_posix("/plain/path"), "'/plain/path'");
assert_eq!(quote_posix("with space"), "'with space'");
assert_eq!(quote_posix("$(whoami)"), "'$(whoami)'");
assert_eq!(quote_posix("it's"), r#"'it'\''s'"#);
assert_eq!(quote_posix(""), "''");