zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Marko Myllynen <myllynen@redhat.com>
Cc: zsh workers <zsh-workers@zsh.org>
Subject: Re: Update _virsh completion
Date: Sun, 4 Sep 2016 18:26:13 +0000	[thread overview]
Message-ID: <20160904182613.GA2185@fujitsu.shahaf.local2> (raw)
In-Reply-To: <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


  reply	other threads:[~2016-09-04 18:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-29  8:03 Marko Myllynen
2016-08-31 17:49 ` Daniel Shahaf
2016-08-31 21:44   ` Oliver Kiddle
2016-09-01 16:01     ` Daniel Shahaf
2016-09-02  9:36   ` Marko Myllynen
2016-09-02 18:20     ` Daniel Shahaf
2016-09-04 18:26       ` Daniel Shahaf [this message]
2016-09-05  6:29       ` Marko Myllynen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160904182613.GA2185@fujitsu.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=myllynen@redhat.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).