Skip to main content

quote_fish

Function quote_fish 

Source
pub fn quote_fish(value: &str) -> String
Expand description

Quote a value for fish.

fish single quotes are not POSIX single quotes: they do process \\ and \', so both are escaped and everything else — $, backticks, newlines — is literal.

use majordomus_cli::environment::shell::quote_fish;
assert_eq!(quote_fish("/plain/path"), "'/plain/path'");
assert_eq!(quote_fish("it's"), r"'it\'s'");
assert_eq!(quote_fish(r"back\slash"), r"'back\\slash'");
assert_eq!(quote_fish("$(whoami)"), "'$(whoami)'");