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

Problem with _arguments and invalid options



Currently, invalid (not listed in description) options are not handled very
nicely. Here is half-hearted example of sudo completion:

_arguments \
	'-V[show version]' \
	'-l[list commands]' \
	'-h[show help]' \
	'-v[validate timestamp file]' \
	'-k[remove timestamp file]' \
	'-b[run command in background]' \
	'-r:Kerberos realm:' \
	'-p:prompt:' \
	'-u:user name:_users' \
	'-s[run SHELL]' \
	'-H[set HOME environment variable]' \
	'*::complete command and/or arguments:_normal'

And now

bor@itsrm2:~/.zsh.d/completion%> sudo -z TAB
bor@itsrm2:~/.zsh.d/completion%> sudo -z _normal: bad option: -z [33]
_
--- file
_sudo     _umount

What's worse - if a command does not list `-s', but you *do* give `-s' - it
seems to be propagated downward and interpreted by _arguments itself (or some
other function, dunno). Just remove definition for -s from above and try:

bor@itsrm2:~/.zsh.d/completion%> sudo -u nTAB
bor@itsrm2:~/.zsh.d/completion%> sudo -u n
--- user
nerv     nobody   nuucp

but

bor@itsrm2:~/.zsh.d/completion%> sudo -s -u nTAB
B-e-e-p

and

bor@itsrm2:~/.zsh.d/completion%> sudo -s -u TAB
bor@itsrm2:~/.zsh.d/completion%> sudo -s -u _
--- file
_sudo     _umount


/andrej



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