Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: _libvirt, $opt_args, and noglob
- X-seq: zsh-workers 39199
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: _libvirt, $opt_args, and noglob
- Date: Tue, 6 Sep 2016 23:46:46 +0000
- Cc: Marko Myllynen <myllynen@xxxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= daniel.shahaf.name; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=lUuUFP3YZB/RCmk8hadNJk8JDJk=; b=y8hKdV y3+ISmUiZcIlUmqxD4QT4iwzMftlqhaCf+zEHIWp7/XX59jVfRQaPr2G3yP07189 48scmwfTqzmBYvTy6Lv92kRGvv8Rd74s/agL4ScFr0HLUCL2KpiS2dezkjmD2L4e ARC9+4/uq4OnRubIr9ytnKYVLvPX0XA4/URQo=
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=lUuUFP3YZB/RCmk8hadNJk8JDJk=; b=e2DzQ zXmNaEgbC7NSjqDPqTBlFZjUDOwp0peq+1Y8Lis+Ys4klrJ/kpjSoQMiBAZYzp4o 1UtqV51xHaHJ2Hnj8UnJ4hAtJZc5Cd/fIXf8DXU1nqE3RY7Z+HC9oCnE2zMbvONC i8hy8TF34mqbN6iAwD+lYhy4FtpjC2FbfR7ZBU=
- In-reply-to: <20160904182622.GA32454@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: <20160904182622.GA32454@fujitsu.shahaf.local2>
Daniel Shahaf wrote on Sun, Sep 04, 2016 at 18:26:22 +0000:
> In the special case of _libvirt, simply adding noglob to the
> _call_program arguments would probably fix this.
Done, but the last line touches the sudo invocation from Oliver's
gain-privileges patch. Oliver: shall I wait with committing this until
you've committed gain-privileges?
[[[
diff --git a/Completion/Unix/Command/_libvirt b/Completion/Unix/Command/_libvirt
index 658e197..2a0a34c 100644
--- a/Completion/Unix/Command/_libvirt
+++ b/Completion/Unix/Command/_libvirt
@@ -140,51 +140,51 @@ case $state in
local -a values
case $words[CURRENT-1] in
--domain)
- values=( $(_call_program domains "virsh $conn_opt list ${dom_opts[$cmd]:-"--all"} --name") )
+ values=( $(_call_program domains "noglob virsh $conn_opt list ${dom_opts[$cmd]:-"--all"} --name") )
[[ -n $values ]] && _wanted domains expl domain compadd ${=values} && return 0
return 1
;;
--interface)
- values=( ${${${${(f):-"$(_call_program interfaces "virsh $conn_opt iface-list ${iface_opts[$cmd]:-"--all"}")"}/ Name*/}:#---*}/ */} )
+ values=( ${${${${(f):-"$(_call_program interfaces "noglob virsh $conn_opt iface-list ${iface_opts[$cmd]:-"--all"}")"}/ Name*/}:#---*}/ */} )
[[ -n $values ]] && _wanted interfaces expl interface compadd ${=values} && return 0
return 1
;;
--network)
- values=( $(_call_program networks "virsh $conn_opt net-list ${net_opts[$cmd]:-"--all"} --name") )
+ values=( $(_call_program networks "noglob virsh $conn_opt net-list ${net_opts[$cmd]:-"--all"} --name") )
[[ -n $values ]] && _wanted networks expl network compadd ${=values} && return 0
return 1
;;
--device)
- values; values=( $(_call_program nodedevs "virsh $conn_opt nodedev-list") )
+ values; values=( $(_call_program nodedevs "noglob virsh $conn_opt nodedev-list") )
[[ -n $values ]] && _wanted devices expl device compadd ${=values} && return 0
return 1
;;
--nwfilter)
- values=( ${${${${(f):-"$(_call_program nwfilters "virsh $conn_opt nwfilter-list")"}/ UUID*/}:#---*}/ */} )
+ values=( ${${${${(f):-"$(_call_program nwfilters "noglob virsh $conn_opt nwfilter-list")"}/ UUID*/}:#---*}/ */} )
[[ -n $values ]] && _wanted nwfilters expl nwfilter compadd ${=values} && return 0
return 1
;;
--pool)
- values=( ${${${${(f):-"$(_call_program pools "virsh $conn_opt pool-list ${pool_opts[$cmd]:-"--all"}")"}/ Name*/}:#---*}/ */} )
+ values=( ${${${${(f):-"$(_call_program pools "noglob virsh $conn_opt pool-list ${pool_opts[$cmd]:-"--all"}")"}/ Name*/}:#---*}/ */} )
[[ -n $values ]] && _wanted pools expl pool compadd ${=values} && return 0
return 1
;;
--secret)
- values=( ${${${${(f):-"$(_call_program secrets "virsh $conn_opt secret-list")"}/ UUID*/}:#---*}/ */} )
+ values=( ${${${${(f):-"$(_call_program secrets "noglob virsh $conn_opt secret-list")"}/ UUID*/}:#---*}/ */} )
[[ -n $values ]] && _wanted secrets expl secret compadd ${=values} && return 0
return 1
;;
--snapshotname)
local dom ; (( ${(k)words[(I)--domain]} > 0 )) && dom=${words[1+${(k)words[(I)--domain]}]}
[[ -z $dom ]] && return 1
- values=( ${${${${(f):-"$(_call_program snapshots "virsh $conn_opt snapshot-list --domain ${(q)dom} 2>/dev/null")"}/ Name*/}:#---*}/ */} )
+ values=( ${${${${(f):-"$(_call_program snapshots "noglob virsh $conn_opt snapshot-list --domain ${(q)dom} 2>/dev/null")"}/ Name*/}:#---*}/ */} )
[[ -n $values ]] && _wanted snapshots expl snapshot compadd ${=values} && return 0
return 1
;;
--vol)
local pool ; (( ${(k)words[(I)--pool]} > 0 )) && pool=${words[1+${(k)words[(I)--pool]}]}
[[ -z $pool ]] && return 1
- values=( ${${${${(f):-"$(_call_program volumes "virsh $conn_opt vol-list --pool ${(q)pool} 2>/dev/null")"}/ Name*/}:#---*}/ */} )
+ values=( ${${${${(f):-"$(_call_program volumes "noglob virsh $conn_opt vol-list --pool ${(q)pool} 2>/dev/null")"}/ Name*/}:#---*}/ */} )
[[ -n $values ]] && _wanted volumes expl volume compadd ${=values} && return 0
return 1
;;
@@ -199,7 +199,7 @@ case $state in
# Allow passing domain without --domain with few of the most used commands
if [[ $cmd == (destroy|reboot|reset|start|shutdown) ]]; then
if [[ $words[CURRENT-1] == $cmd ]]; then
- values=( $(_call_program domains "virsh $conn_opt list ${dom_opts[$cmd]:-"--all"} --name") )
+ values=( $(_call_program domains "noglob virsh $conn_opt list ${dom_opts[$cmd]:-"--all"} --name") )
[[ -n $values ]] && _wanted domains expl domain compadd ${=values} && return 0
fi
fi
@@ -224,7 +224,7 @@ case $state in
local srv ; (( ${(k)words[(I)--server]} > 0 )) && srv=${words[1+${(k)words[(I)--server]}]}
[[ -z $srv ]] && return 1
[[ -n ${srv//[[:alnum:]]} ]] && return 1
- _wanted clients expl client compadd ${=${${(f):-"$(sudo virt-admin ${(Q)conn_opt} srv-clients-list --server $srv 2>/dev/null)"}/ [a-z]*}//[^0-9]} && return 0
+ _wanted clients expl client compadd ${=${${(f):-"$(noglob sudo virt-admin ${(Q)conn_opt} srv-clients-list --server $srv 2>/dev/null)"}/ [a-z]*}//[^0-9]} && return 0
fi
[[ -z $_cache_virt_admin_cmd_opts[$cmd] ]] && \
_cache_virt_admin_cmd_opts[$cmd]=${(M)${${${${=${(f)"$(_call_program virt-admin virt-admin help $cmd 2>&1)"}}/\[}/\]}/\;}:#-[-0-9A-Za-z]*}
]]]
> This might not work for arbitrary other callsites, though. I think
> the general fix would be to backslash-escape the characters that "need
> escaping only when noglob is not present". (Neither (q) nor (b) do
> this since both of them escape backslashes.)
Leaving this for Future Work.
Cheers,
Daniel
Messages sorted by:
Reverse Date,
Date,
Thread,
Author