pub fn quote(value: &str) -> StringExpand description
Quote a value for safe shell usage
The value is always treated as literal text - exactly one argument, spaces
and quote characters included - which is what "$var" does in sh.
ยงExamples
use command_stream::quote::quote;
// Safe characters are passed through unchanged
assert_eq!(quote("hello"), "hello");
assert_eq!(quote("/path/to/file"), "/path/to/file");
// Special characters are quoted
assert_eq!(quote("hello world"), "'hello world'");
// Paths with spaces stay a single argument
assert_eq!(quote("/My Documents/report.txt"), "'/My Documents/report.txt'");
// Single quotes in strings are escaped
assert_eq!(quote("it's"), "'it'\\''s'");
// Empty strings are quoted
assert_eq!(quote(""), "''");