Allow to escape escape char to in commands (#191).
authorDaniel Carl <danielcarl@gmx.de>
Mon, 16 Mar 2015 21:13:20 +0000 (22:13 +0100)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 16 Mar 2015 21:13:20 +0000 (22:13 +0100)
This patch fixes a misbehaviour in the way the escaping is done for commands
given via inputbox or config file. The previous logic for the lhs of a command
used '\' to escape the ' '. But to get a single '\' it's needed to use '\\'.
But the '\\' was not taken as a single backslash.
Now the backslash escapes ' ' as well as '\'. A backslash followed by any
other char is taken as is.

src/ex.c

index a75ae5c..711190a 100644 (file)
--- a/src/ex.c
+++ b/src/ex.c
@@ -648,8 +648,9 @@ static gboolean parse_lhs(const char **input, ExArg *arg)
             if (!*input) {
                 /* if input ends here - use only the backslash */
                 g_string_append_c(arg->lhs, quote);
-            } else if (**input == ' ') {
-                /* escaped whitespace becomes only whitespace */
+            } else if (**input == ' ' || **input == quote) {
+                /* Escaped whitespace becomes only whitespace and escaped '\'
+                 * becomes '\' */
                 g_string_append_c(arg->lhs, **input);
             } else {
                 /* put escape char and next char into the result string */