diff --git a/src/util.cpp b/src/util.cpp index 38027855..92c61bb0 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -54,9 +54,6 @@ std::string escape (const std::string& input, int c) //////////////////////////////////////////////////////////////////////////////// std::string quoteIfNeeded (const std::string& input) { - if (input[0] == '"' || input[0] == '\'') - return input; - auto quote = input.find ('"'); auto space = input.find (' '); auto op = input.find_first_of ("+-/()<^!=~_"); diff --git a/test/util.t.cpp b/test/util.t.cpp index 83e4a33c..549506d9 100644 --- a/test/util.t.cpp +++ b/test/util.t.cpp @@ -43,6 +43,7 @@ int main (int, char**) // std::string quoteIfNeeded (const std::string& input) t.is (quoteIfNeeded ("foo"), "foo", "quoteIfNeeded 'foo' --> 'foo'"); t.is (quoteIfNeeded ("f o o"), "\"f o o\"", "quoteIfNeeded 'f o o' --> '\"f o o\"'"); + t.is (quoteIfNeeded ("\"a b\" c"), "\"\\\"a b\\\" c\"", "quoteIfNeeded '\"a b\" c' --> '\"\\\"a b\\\" c'\""); { std::set unjoined;