pub fn escape<T: Into<OsString>>(s: T) -> Vec<u8>
Expand description

Escape a string of bytes into a new Vec<u8>.

This will return one of the following:

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.