From nobody Sun Feb 8 19:45:38 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=1618925719; cv=none; d=zohomail.com; s=zohoarc; b=a4Qip9nO5DpYrVF1ccmfLlJROrLxI0D8est8GsGo2LVDxxt1GWLcEQoEo7mle1h+5MQYQxeGCa+lkk2D5KU5bxmdoifEVsiky8Zb8+G0BbPMpYp7iQtEbVcv0VU6fy45Mcuiimn7bPeVsrZKu7bdPNAD079k+FUCGZ/cuji8cio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618925719; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=aPyffgBWGowCysmj4epcsm/aw7VOLEUwRgx222RmzOA=; b=DTdH+8ny5zIiqHb5eCnZwc8S4wB5/k65bl2cO+KhrrY3G5UYJQzFPXbyblBZmWwDkGiNdlog+idmDN9N5dWrB0k2BvSBeGAeoIwlXk05mpzb5QUL2znTz4Ec2blCbqag3Eunqi7MfcuneZMNWQtAJOfj84DeRWYshD2Uxh/JgFo= 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 1618925719798668.8178186381081; Tue, 20 Apr 2021 06:35:19 -0700 (PDT) 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-149--l5D9qW0NyyRi-V2vZXncQ-1; Tue, 20 Apr 2021 09:35:16 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3870B107ACCA; Tue, 20 Apr 2021 13:35:09 +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 202BF3A47; Tue, 20 Apr 2021 13:35:07 +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 15C1F44A58; Tue, 20 Apr 2021 13:35:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 13KDZ3SD001050 for ; Tue, 20 Apr 2021 09:35:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5398118A60; Tue, 20 Apr 2021 13:35:03 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.195.241]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB1B618B4B for ; Tue, 20 Apr 2021 13:34:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618925718; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aPyffgBWGowCysmj4epcsm/aw7VOLEUwRgx222RmzOA=; b=HnMgLHMvrSjdjJOsKrMzrdiS3jX8XKFL5vEM6ojYc+vkiom/tKdfnpDZzsPcbQsHPkI0GB rsj6ziWoPTGNP5nEIB0LTzBu3/a1TcnZcwfS82JyWIy6nKvMvFlOko24G89Sbc9dyRfzLe v5CeuuWdsGeqDdmTfbfTYz2DpfP9h34= X-MC-Unique: -l5D9qW0NyyRi-V2vZXncQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] bash-completion: Fix argument passing to $1 Date: Tue, 20 Apr 2021 15:34:53 +0200 Message-Id: <8151dfefc6209eb3840b733b97d722ca77022191.1618925685.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.15 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" Our vsh bash completion string is merely just a wrapper over virsh/virt-admin complete (cmdComplete) - a hidden command that uses internal readline completion to generate list of candidates. But this means that we have to pass some additional arguments to the helper process: e.g. connection URI and R/O flag. Candidates are printed on a separate line each (and can contain space), which means that when bash is reading the helper's output into an array, it needs to split items on '\n' char - hence the IFS=3D$'\n' prefix on the line executing the helper. This was introduced in b889594a70. But this introduced a regression - those extra arguments we might pass are stored in a string and previously were split on a space character (because $IFS was kept untouched and by default contains space). But now, after the fix that's no longer the case and thus virsh/virt-admin sees ' -r -c URI' as one argument. The solution is to take $IFS out of the picture by storing the extra arguments in an array instead of string. Fixes: b889594a7092440dc916e3f43eeeaca2684571ee Signed-off-by: Michal Privoznik Reviewed-by: Erik Skultety --- tools/bash-completion/vsh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/bash-completion/vsh b/tools/bash-completion/vsh index bbb25fc3eb..402945a8c5 100644 --- a/tools/bash-completion/vsh +++ b/tools/bash-completion/vsh @@ -30,12 +30,12 @@ _vsh_complete() c=3D$((++c)) done =20 - CMDLINE=3D + CMDLINE=3D( ) if [ -n "${RO}" ]; then - CMDLINE=3D"${CMDLINE} -r" + CMDLINE+=3D("-r") fi if [ -n "${URI}" ]; then - CMDLINE=3D"${CMDLINE} -c ${URI}" + CMDLINE+=3D("-c" "${URI}") fi =20 INPUT=3D( "${COMP_WORDS[@]:$i:$COMP_CWORD}" ) @@ -56,7 +56,7 @@ _vsh_complete() # the name of the command whose arguments are being # completed. # Therefore, we might just run $1. - IFS=3D$'\n' A=3D($($1 ${CMDLINE} complete -- "${INPUT[@]}" 2>/dev/null= )) + IFS=3D$'\n' A=3D($($1 ${CMDLINE[@]} complete -- "${INPUT[@]}" 2>/dev/n= ull)) =20 COMPREPLY=3D($(compgen -W "${A[*]%--}" -- ${cur})) __ltrim_colon_completions "$cur" --=20 2.26.3