diff --git a/ChangeLog b/ChangeLog index f216b4ce9..c6a05a034 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,8 @@ Thanks to Florian. - TW #1955 Adding tasks in context. Thanks to Jean-Francois Joly, Matt Smith. +- TW #1960 Fixed bug with double escaped single quotes. + Thanks to Sebastian Uharek - TW #2004 "shell" should not be expand to "exec tasksh" Thanks to Arvedui - TW #2007 Compute number of current tasks correctly diff --git a/src/CLI2.cpp b/src/CLI2.cpp index 2240d026e..cf6ddd61f 100644 --- a/src/CLI2.cpp +++ b/src/CLI2.cpp @@ -417,8 +417,18 @@ void CLI2::lexArguments () else { std::string quote = "'"; - std::string escaped = _original_args[i].attribute ("raw"); - escaped = str_replace (escaped, quote, "\\'"); + // Escape unescaped single quotes + std::string escaped = ""; + bool nextEscaped = false; + for(auto c : _original_args[i].attribute ("raw")) { + if(!nextEscaped && (c == '\\')) { + nextEscaped = true; + } else { + if(c == '\'' && !nextEscaped) escaped += "\\"; + nextEscaped = false; + } + escaped += c; + } std::string::size_type cursor = 0; std::string word;