diff --git a/README.md b/README.md index 4cf2c79..377d655 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Inspired by the Haskell [shell-escape][] package, which is the most comprehensive implementation of shell escaping I've yet seen. For now this package implements escaping for `/bin/sh`-like shells, [GNU -Bash][gnu-bash] and [fish][]. +Bash][gnu-bash] and [fish][]. Please read the documentation for each module to learn about some limitations and caveats. @@ -30,14 +30,14 @@ assert_eq!(Sh::quote("foobar"), b"foobar"); assert_eq!(Fish::quote("foobar"), b"foobar"); assert_eq!(Bash::quote("foo bar"), b"$'foo bar'"); assert_eq!(Sh::quote("foo bar"), b"'foo bar'"); -assert_eq!(Fish::quote("foo bar"), b"'foobar'"); +assert_eq!(Fish::quote("foo bar"), b"'foo bar'"); ``` It's also possible to use the extension trait [`QuoteRefExt`] which provides a [`quoted`] function: ```rust -use shell_quote::{Bash, Sh, QuoteRefExt}; +use shell_quote::{Bash, Sh, Fish, QuoteRefExt}; let quoted: Vec = "foo bar".quoted(Bash); assert_eq!(quoted, b"$'foo bar'"); let quoted: Vec = "foo bar".quoted(Sh); diff --git a/src/fish.rs b/src/fish.rs index 4bc84dd..8198276 100644 --- a/src/fish.rs +++ b/src/fish.rs @@ -33,7 +33,7 @@ impl Fish { /// ``` /// # use shell_quote::{Fish, Quoter}; /// assert_eq!(Fish::quote("foobar"), b"foobar"); - /// assert_eq!(Fish::quote("foo 'bar"), b"'foo \'bar'"); + /// assert_eq!(Fish::quote("foo 'bar"), b"'foo \\'bar'"); /// ``` pub fn quote<'a, S: ?Sized + Into>>(s: S) -> Vec { let sin: Quotable<'a> = s.into(); @@ -60,7 +60,7 @@ impl Fish { /// Fish::quote_into("foobar", &mut buf); /// buf.push(b' '); // Add a space. /// Fish::quote_into("foo 'bar", &mut buf); - /// assert_eq!(buf, b"foobar 'foo \'bar'"); + /// assert_eq!(buf, b"foobar 'foo \\'bar'"); /// ``` /// pub fn quote_into<'a, S: ?Sized + Into>>(s: S, sout: &mut Vec) { @@ -114,7 +114,7 @@ fn escape_chars(esc: Vec, sout: &mut Vec) { is_there_char_after_last_single_quote = false; } else { // Pop the useless single quote - debug_assert_eq!(sout.pop(), Some(b'\'')); + assert_eq!(sout.pop(), Some(b'\'')); sout.extend(literal); sout.push(b'\''); is_there_char_after_last_single_quote = false; @@ -153,6 +153,6 @@ fn escape_chars(esc: Vec, sout: &mut Vec) { sout.push(b'\''); } else { // Pop the useless single quote - debug_assert_eq!(sout.pop(), Some(b'\'')); + assert_eq!(sout.pop(), Some(b'\'')); } }