From nobody Mon Feb 2 07:31:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1768823297; cv=none; d=zohomail.com; s=zohoarc; b=eo71NUKD/CqsahdAa2ZH1OnE2mW4GGg5YZpT9O8zVmAtRKxaKL04OZXlbDVyRvdtkM6a9lM492MlwQBUlUB4YjTsrSEvW2oXVy3FRpG/AahSvYIXpiPB+fL6Mjq0RiAjxFKmYeNrGKAGF/j8/O7L6QOut2GczR+WNhxyBdgSlgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1768823297; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=dzMtv/rP6ULWIWIcK8QmZiFc4dek7E+p7EP11MkxYj4=; b=L7LF2Lwh3wSKQCU4fJ+NeA56DnRLmILZYtrVtXRCPZNJSU2OspU+KF22M/DvJ3ytNFSfc9app6AgO5ECipkinU9TU0hU8glbna35GB4V9kyVknFA66hvwJSsUKPfjdpRSart8zSjXnXz5cl/bZNo/1mRJ734QAlCg8kY43LwVH4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1768823297700687.6380980250261; Mon, 19 Jan 2026 03:48:17 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id DD6F543ED3; Mon, 19 Jan 2026 06:48:16 -0500 (EST) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id D008543F2B; Mon, 19 Jan 2026 06:46:57 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id C8F5841C1F; Mon, 19 Jan 2026 06:46:49 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 467AD41BA1 for ; Mon, 19 Jan 2026 06:46:49 -0500 (EST) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-460-WNmzsgHTM0GXThAiMw3kWw-1; Mon, 19 Jan 2026 06:46:47 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E3E8E19560A6 for ; Mon, 19 Jan 2026 11:46:46 +0000 (UTC) Received: from moe (unknown [10.43.3.236]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4D5D119560A7 for ; Mon, 19 Jan 2026 11:46:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768823209; h=from:from: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; bh=dzMtv/rP6ULWIWIcK8QmZiFc4dek7E+p7EP11MkxYj4=; b=Jm6x03ty1ansH0DPCDvdmC1Xn8M7Hm21Bjr+fkHQ/Ijw1/4lQfVFDT5/jjUlHWa3J0boAf PPdUlIamvshxxMDoUoas3y4WHX6rhoSAl4lvuzDOschyjQ3gr8mz6nTJL0m1y+kho+9ghU ciWB6X4BUoVzF/IuWA5LkCUDIjv1SPM= X-MC-Unique: WNmzsgHTM0GXThAiMw3kWw-1 X-Mimecast-MFC-AGG-ID: WNmzsgHTM0GXThAiMw3kWw_1768823207 To: devel@lists.libvirt.org Subject: [PATCH v2 1/3] libvirt-guests.sh: Declare and assign separately to avoid masking return values Date: Mon, 19 Jan 2026 12:46:41 +0100 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: raI7YYd_W366PXKBrwF53TiJ6lrcj79DNXElxJOhKpQ_1768823207 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JBHDLRA7QVR2LB5WAPVSDTMCJHDNSFZI X-Message-ID-Hash: JBHDLRA7QVR2LB5WAPVSDTMCJHDNSFZI X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1768823299926158500 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik In Bash, the following code does not do what you think it does: func() { local var=3D$(false) echo $? } Here, '0' is echoed even though false is designed to exit with a non-zero code. This is because in fact the last executed command is 'local' not 'false' and thus '$?' contains zero as in "yeah, the variable is successfully declared" [1]. In our libvirt-guest shell script, there are a few places like this. Fix them. 1: bash_builtins(1) Signed-off-by: Michal Privoznik --- tools/libvirt-guests.sh.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/libvirt-guests.sh.in b/tools/libvirt-guests.sh.in index f2db1282ad..e05bfdba61 100644 --- a/tools/libvirt-guests.sh.in +++ b/tools/libvirt-guests.sh.in @@ -106,8 +106,9 @@ test_connect() list_guests() { local uri=3D"$1" local persistent=3D"$2" - local list=3D"$(run_virsh_c "$uri" list --uuid $persistent)" + local list =20 + list=3D"$(run_virsh_c "$uri" list --uuid $persistent)" if [ $? -ne 0 ]; then RETVAL=3D1 return 1 @@ -482,7 +483,8 @@ stop() { =20 eval_gettext "Running guests on \$uri URI: " =20 - local list=3D"$(list_guests "$uri")" + local list + list=3D"$(list_guests "$uri")" if [ $? -eq 0 ]; then local empty=3Dtrue for uuid in $list; do @@ -498,7 +500,8 @@ stop() { fi =20 if "$persistent_only"; then - local transient=3D"$(list_guests "$uri" "--transient")" + local transient + transient=3D"$(list_guests "$uri" "--transient")" if [ $? -eq 0 ]; then local empty=3D"true" local uuid=3D --=20 2.52.0