Function shell_quote::bash::escape
source · [−]Expand description
Escape a string of bytes into a new Vec<u8>.
This will return one of the following:
- The string as-is, if no escaping is necessary.
- An ANSI-C escaped string, like
$'foo\nbar'.
See escape_into for a variant that extends an existing Vec instead of
allocating a new one.
Examples
assert_eq!(bash::escape("foobar"), b"foobar");
assert_eq!(bash::escape("foo bar"), b"$'foo bar'");The input argument is Into<OsString>, so you can pass in regular Rust
strings, PathBuf, and so on. For a regular Rust string it will be quoted
byte for byte.