Struct shell_quote::Fish
source · pub struct Fish;Expand description
Quote byte strings for use with fish.
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<'a, S: ?Sized + Into<Quotable<'a>>>(s: S) -> Vec<u8> ⓘ
pub fn quote<'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 for a variant that extends an
existing Vec instead of allocating a new one.
§Examples
assert_eq!(Fish::quote("foobar"), b"foobar");
assert_eq!(Fish::quote("foo 'bar"), b"'foo \\'bar'");Trait Implementations§
impl Copy for Fish
impl Quoter 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
Mutably borrows from an owned value. Read more
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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)
🔬This is a nightly-only experimental API. (
clone_to_uninit)