Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Update _virsh completion
- X-seq: zsh-workers 39171
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Marko Myllynen <myllynen@xxxxxxxxxx>
- Subject: Re: Update _virsh completion
- Date: Sun, 4 Sep 2016 18:26:13 +0000
- Cc: zsh workers <zsh-workers@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=	daniel.shahaf.name; h=cc:content-transfer-encoding:content-type	:date:from:in-reply-to:message-id:mime-version:references	:subject:to:x-sasl-enc:x-sasl-enc; s=mesmtp; bh=7PBFngGkF0wr65VD	2bz6rVLp8I4=; b=qP2StqbcSRJZPqg80BvnRckatH/hLKioYYqXmjgWK7wb+2/L	hzCIMAZ8BDfmsrSqoP2bmdWr79Un4jx4KosBj4aUEeiZfEZjJgb163qxgwyPtnG/	K+HtehKCrXaQkWGf5EgLAQuizzW3kEQ/+cobOImZXhu0sF+zVaUsgKuyOcs=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=	messagingengine.com; h=cc:content-transfer-encoding:content-type	:date:from:in-reply-to:message-id:mime-version:references	:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=7PBFngGkF0wr65V	D2bz6rVLp8I4=; b=JMccnGKXXLOs7Kg5XtJuWzRv6+vayGH9XDSeswyaffMFjkN	jWzQlckJH//opZhK4AUYA183iq4h9XxRIdxTmk4PmdTukdwfcTGPexh4/viG5d9E	193q7cSwG4zE0dkDqOGWFOHj4zMLC83ZbPmjpsJwCGEzgCF9g37vTkk6UkhU=
- In-reply-to: <20160902182024.GA26517@fujitsu.shahaf.local2>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <f957d4aa-d989-6252-14d2-0cc57afdab68@redhat.com> <20160831174915.GA11043@fujitsu.shahaf.local2> <bb575beb-c685-1864-9ba2-bf36f97a5753@redhat.com> <20160902182024.GA26517@fujitsu.shahaf.local2>
Daniel Shahaf wrote on Fri, Sep 02, 2016 at 18:20:24 +0000:
> Marko Myllynen wrote on Fri, Sep 02, 2016 at 12:36:44 +0300:
> > Looks like 'libvirtd\:///system' instead of 'libvirtd:///system' is
> > passed to virt-admin without (Q). Perhaps there's more optimal/safe
> > alternative here which I'm missing?
> > 
> 
> I'm not sure why the colon gets escaped.  Typically, colons get escaped
> when constructing a spec argument to _arguments or _describe.
The colon is escaped by _arguments:
.
                                        For options that have more than one
              argument these are given as one string, separated by colons.
              All colons in the original arguments are preceded with
              backslashes.
.
By "more than one argument" the manual refers to specs such as
«_arguments : -c:arg1:_users:arg2:_hosts».  This spec means -c takes
two arguments in separate words.   (Example: «foo -c danielsh localhost»
would yield «opt_args=(-c danielsh:localhost)».)
Undoing that escaping would be:
diff --git a/Completion/Unix/Command/_libvirt b/Completion/Unix/Command/_libvirt
index ad4c3b8..f887426 100644
--- a/Completion/Unix/Command/_libvirt
+++ b/Completion/Unix/Command/_libvirt
@@ -116,6 +116,7 @@ esac
 local -a conn_opt
 if [[ -n ${(v)opt_args[(I)-c|--connect]} ]]; then
   local uri=${(v)opt_args[(I)-c|--connect]}
+  uri=${uri//(#m)\\([\\:])/${MATCH[2]}} # opt_args elements are colon-escaped
   # For the libvirt remote URI syntax, see:
   # https://libvirt.org/guide/html/Application_Development_Guide-Architecture-Remote_URIs.html
   [[ -z ${(Q)uri//([[:alnum:]]|+|:|\/|@|-|\.|\?|=)} ]] && \
This patch changes the behaviour of «virsh -c qemu\:///system start
--domain <TAB>».
See also the _arguments email I'm about to send.
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author