From nobody Mon Feb 9 09:08:32 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611667743; cv=none; d=zohomail.com; s=zohoarc; b=Q+BRxCC3AUsnSUzX2YBofj8XNoxl34I3Bu4iSTJdrzC7NZLaTNlNCJ5/zcFWN/c5MWJL0XR0aSPI16FEH6MFZSStUZua6tEFMryW7WAB9/qNEAV/Dd2prSj6ZikL1QDPI31aVZx9haJkPz6bGTT7+ooH8LckXJiTspFkhglR6sI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611667743; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MW4F0MaxxqtKbiu2M8CRtmP4D71VMkWLu6Q+w7Xiz9I=; b=W5vXSYDPWXTYmqVJF8pS1axf/o4gQcSCyQfpMVZam6kvr+wrlntDMqbRJfpmrg6jI8jFW3ujyUqp+PkOaLHveYuzOcebAdY3M6LmuAgIcmPCbIm1oqHbaWWuGbvBOflW52KZwdtNW9kLvyIlumH0FpVV64Gl97xP3m4XGQxgn44= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1611667743868318.0534279946975; Tue, 26 Jan 2021 05:29:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-157-u4BkGRf0MjGhH0MkWD1v2Q-1; Tue, 26 Jan 2021 08:27:43 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 719C2107ACF9; Tue, 26 Jan 2021 13:27:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5046A5D9E2; Tue, 26 Jan 2021 13:27:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0E0FD5002D; Tue, 26 Jan 2021 13:27:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10QDRW4Z001413 for ; Tue, 26 Jan 2021 08:27:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9E8B25C26D; Tue, 26 Jan 2021 13:27:32 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 209D15C73F for ; Tue, 26 Jan 2021 13:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611667742; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MW4F0MaxxqtKbiu2M8CRtmP4D71VMkWLu6Q+w7Xiz9I=; b=fGddLht9eYT8oPDd5qjurn0qZP25QbKDys0v3SxWXBcLcDtAzPbxZLx4jwa/H9AMJO8Ah3 Ch5xWd1NovmSNFtDgByrvfx1ySvDLK6Y+OFMIFpmPcriOoUP/M8yq5fIcdePOP6yHuVC4w LIrWs7Uk/h99cy7aKDZpUlNcKbEV7CY= X-MC-Unique: u4BkGRf0MjGhH0MkWD1v2Q-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 8/9] vsh: Allow double quotes imbalance for auto completion in vshCommandStringGetArg() Date: Tue, 26 Jan 2021 14:27:12 +0100 Message-Id: <17994097b94b3e07001302c84c2c77ec6b71d722.1611667532.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If user is trying to auto complete a value that contains a space, they have two options: use backslash to escape space or use qotes, like this: virsh # start --domain "domain with space However, in this case our tokenizer sees imbalance in (double) quotes: there is a starting one that's missing it's 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 --- tools/vsh.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index e5c6cebebb..53a84b9d95 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -1418,7 +1418,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *pa= rser, vshCmd **partial) if (optstr) tkdata =3D optstr; else - tk =3D parser->getNextArg(ctl, parser, &tkdata, tr= ue); + tk =3D parser->getNextArg(ctl, parser, &tkdata, pa= rtial =3D=3D NULL); if (tk =3D=3D VSH_TK_ERROR) goto syntaxError; if (tk !=3D VSH_TK_ARG) { @@ -1673,10 +1673,16 @@ vshCommandStringGetArg(vshControl *ctl, vshCommandP= arser *parser, char **res, =20 *q++ =3D *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 =3D false), but it's not valid + * when parsing real command (report=3D true). */ + if (report) { vshError(ctl, "%s", _("missing \"")); - return VSH_TK_ERROR; + return VSH_TK_ERROR; + } } =20 *q =3D '\0'; --=20 2.26.2