]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
vsh: Don't break word on backslash
authorMichal Privoznik <mprivozn@redhat.com>
Thu, 7 Jan 2021 16:58:41 +0000 (17:58 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 26 Jan 2021 15:46:41 +0000 (16:46 +0100)
A backslash is the way we escape characters in virsh. For
instance:

  virsh # start domain\ with\ long\ name

For readline completion, we do not want to get four separate
words ("domain", "with", "long", "name").  This means, that we
can't use virBufferEscapeShell() because it doesn't escape spaces
the way we want.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
tools/vsh.c

index 54253afa7220725282f3328ee2a9a30a8d40bfa7..9856088126ba80b15a0c81ef4b996f7aa78bd269 100644 (file)
@@ -2773,7 +2773,7 @@ vshReadlineParse(const char *text, int state)
     if (ret &&
         !rl_completion_quote_character) {
         g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-        virBufferEscapeShell(&buf, ret);
+        virBufferEscape(&buf, '\\', " ", "%s", ret);
         VIR_FREE(ret);
         ret = virBufferContentAndReset(&buf);
     }
@@ -2819,7 +2819,7 @@ vshReadlineInit(vshControl *ctl)
     int ret = -1;
     char *histsize_env = NULL;
     const char *histsize_str = NULL;
-    const char *break_characters = " \t\n\\`@$><=;|&{(";
+    const char *break_characters = " \t\n`@$><=;|&{(";
     const char *quote_characters = "\"'";
 
     /* Opaque data for autocomplete callbacks. */