Struct shell_quote::Fish
source · 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: ?Sized + Into<Quotable<'a>>>(s: S) -> Vec<u8> ⓘ
pub fn quote_vec<'a, S: ?Sized + 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'");Trait Implementations§
impl Copy for Fish
Auto Trait Implementations§
impl Freeze for Fish
impl RefUnwindSafe for Fish
impl Send for Fish
impl Sync for Fish
impl Unpin for Fish
impl UnwindSafe for Fish
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)