pub struct Fish;Expand description
Quote byte strings for use with fish.
§⚠️ Warning
Prior to version 3.6.2, fish did not correctly handle some Unicode code points encoded as UTF-8. From the version 3.6.2 release notes:
fish uses certain Unicode non-characters internally for marking wildcards and expansions. It incorrectly allowed these markers to be read on command substitution output, rather than transforming them into a safe internal representation.
At present this crate has no workaround for this issue. Please use fish 3.6.2 or later.
§Notes
The documentation on quoting and escaping characters in fish is
confusing at first, especially when coming from a Bourne-like shell, but
essentially we have to be able to move and and out of a quoted string
context. For example, the escape sequence \t for a tab must be outside
of quotes, single or double, to be recognised as a tab character by fish:
echo 'foo'\t'bar'This emphasises the importance of using the correct quoting module for the target shell.
Implementations§
Source§impl Fish
impl Fish
Sourcepub fn quote_vec<'a, S: Into<Quotable<'a>>>(s: S) -> Vec<u8> ⓘ
pub fn quote_vec<'a, S: Into<Quotable<'a>>>(s: S) -> Vec<u8> ⓘ
Quote 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 escaped string, like
'foo \'bar',\a'ABC'
See quote_into_vec for a variant that
extends an existing Vec instead of allocating a new one.
§Examples
assert_eq!(Fish::quote_vec("foobar"), b"foobar");
assert_eq!(Fish::quote_vec("foo 'bar"), b"foo' \\'bar'");