Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

_libvirt, $opt_args, and noglob



The question mark in «noglob virsh -c foo://bar?» is interpreted by the
_call_program subshell as a pattern, causing _libvirt to fail to find
completions:

(setup)
% zstyle :completion:\*:warnings format 'No matches: %D'    
% functions -T $_comps[libvirt]

% noglob virsh -c qemu:///system? start --domain <TAB>
⋮
+_libvirt:142> values=+_libvirt:142> _call_program domains 'virsh -c qemu\:///system? list --inactive --name'
+_libvirt:142> values=( ) 
No matches: cmdopt

Now create a filename that matches that globbing pattern and try the
command again:

% noglob mkdir -p ./qemu:/system?
% noglob virsh -c qemu:///system? start --domain <TAB>
<works>

I believe the reason it works is that the globbing pattern «qemu:///system?»
gets expanded into the filename «qemu:/system?», which happens to work
just fine as an argument to «virsh -c».

(The backslash in front of the colon here is an independent problem, see 39158.)

In the special case of _libvirt, simply adding noglob to the
_call_program arguments would probably fix this.  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.)

Cheers,

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author