From nobody Mon Feb 9 14:33:49 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1612448066; cv=none; d=zohomail.com; s=zohoarc; b=lW5MeIZuu2of3nkFiQzNkiD7CjPFh6G1vZb0KPDN79vJVgdlx1bMoVZrMYDgDpkjzYbzDxZDBg4E57+tYVneGI1GiytbJgvOrmj0Q7sjkIw0OxVxCunFsvEfVoE7D+itZaVDboBzprsLp3g+NRdBot15DPWap6KLf4PV0yILliI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612448066; 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=nNOAD0tYG0MSKb/hKTgPEhqoV+z3lmnJe9KcjkRSoJs=; b=FZc5P2SAKyaA6Ndnc4F1cPbjRmjvM22JpJii+Rra1d6YCv7LC0GpGHF7SWaLzrhOZPa+cGvc3qMu64lNcRD0Aw0Z5KQzQXtk8r7EYMXL9dEu7rwC8uKQ3DSf202zQAA6kKZaAjst7Sao8RS413Y7HYPc7rBMWJSCbKwvGAWEzvI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 161244806631820.081360364427383; Thu, 4 Feb 2021 06:14:26 -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-567-_PXQRZj7MPqQQq4JDVqXJQ-1; Thu, 04 Feb 2021 09:14:21 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C3337835E27; Thu, 4 Feb 2021 14:14:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1D8760C76; Thu, 4 Feb 2021 14:14:12 +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 66FC31809C92; Thu, 4 Feb 2021 14:14:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 114EDsL4031624 for ; Thu, 4 Feb 2021 09:13:54 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7A94D5D9F4; Thu, 4 Feb 2021 14:13:54 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.72]) by smtp.corp.redhat.com (Postfix) with ESMTP id F09D45D9C9 for ; Thu, 4 Feb 2021 14:13:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612448064; 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=nNOAD0tYG0MSKb/hKTgPEhqoV+z3lmnJe9KcjkRSoJs=; b=Ci3bX2eRUSpGfLl7276QZUsesbciazQS8Mlz09/OXr+yevCQNh320qIIP85Ad1IygsqiS9 zKK6haA7EN1nCbxYOgRxq9LwKe6o9n3p0Gq5lOBuqP5ZQcAPKNb+8aQT4RForUh6NheCMx KXnYeul4OMTGuXmajlfecdPk2COazlo= X-MC-Unique: _PXQRZj7MPqQQq4JDVqXJQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 07/12] vsh: Rewrite opt->type check in vshReadlineParse() Date: Thu, 4 Feb 2021 15:13:32 +0100 Message-Id: <381d2fd560903abda8255359120e8116eb366cc2.1612447905.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 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.12 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" The vshReadlineParse() function is called whenever user hits . If there is no command (or a partially written one), then a list of possible commands is printed to the user. But, if there is a command then its --options are generated. But obviously, we can not generate --options if there already is an --option that's expecting a value. For instance, consider: virsh # start --domain In this case we want to call completer for --domain option, but that's a different story. Anyway, the way that we currently check whether --options list should be generated is checking the type of the last --option. If it isn't DATA, STRING, INT, or ARGV (all these expect a value), then we can generate --option list. Well, writing the condition this way is needlessly verbose and also prone to errors (see d9a320bf97 for example). We know that boolean type does not require a value. This leaves us with the only type that was not mentioned yet - VSH_OT_ALIAS. This is a special type for backwards compatibility and it refers to another --option which can be just any type. Signed-off-by: Michal Privoznik --- tools/vsh.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index 70b7e3e285..f83b2a95a9 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -2765,10 +2765,7 @@ vshReadlineParse(const char *text, int state) if (!cmd) { list =3D vshReadlineCommandGenerator(text); } else { - if (!opt || (opt->type !=3D VSH_OT_DATA && - opt->type !=3D VSH_OT_STRING && - opt->type !=3D VSH_OT_INT && - opt->type !=3D VSH_OT_ARGV)) + if (!opt || opt->type =3D=3D VSH_OT_BOOL) list =3D vshReadlineOptionsGenerator(text, cmd, partial); =20 if (opt && opt->completer) { --=20 2.26.2