mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
vsh: Allow double quotes imbalance for auto completion in vshCommandStringGetArg()
If user is trying to auto complete a value that contains a space, they have two options: use backslash to escape space or use quotes, like this: virsh # start --domain "domain with space<TAB> However, in this case our tokenizer sees imbalance in (double) quotes: there is a starting one that's missing its companion. Well, that's obvious - user is still in process of writing the command. What we need to do in this case is to ignore the imbalance and return success (from the tokenizer) - readline will handle closing the quote properly. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
22904b5702
commit
aad2262b9e
10
tools/vsh.c
10
tools/vsh.c
@ -1418,7 +1418,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser, vshCmd **partial)
|
||||
if (optstr)
|
||||
tkdata = optstr;
|
||||
else
|
||||
tk = parser->getNextArg(ctl, parser, &tkdata, true);
|
||||
tk = parser->getNextArg(ctl, parser, &tkdata, partial == NULL);
|
||||
if (tk == VSH_TK_ERROR)
|
||||
goto syntaxError;
|
||||
if (tk != VSH_TK_ARG) {
|
||||
@ -1673,11 +1673,17 @@ vshCommandStringGetArg(vshControl *ctl, vshCommandParser *parser, char **res,
|
||||
|
||||
*q++ = *p++;
|
||||
}
|
||||
|
||||
if (double_quote) {
|
||||
if (report)
|
||||
/* We have seen a double quote, but not it's companion
|
||||
* ending. It's valid though, in case when we're called
|
||||
* from completer (report = false), but it's not valid
|
||||
* when parsing real command (report= true). */
|
||||
if (report) {
|
||||
vshError(ctl, "%s", _("missing \""));
|
||||
return VSH_TK_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
*q = '\0';
|
||||
parser->pos = p;
|
||||
|
Loading…
Reference in New Issue
Block a user