From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5965 invoked from network); 13 Sep 1999 11:27:45 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Sep 1999 11:27:45 -0000 Received: (qmail 6478 invoked by alias); 13 Sep 1999 11:27:28 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7800 Received: (qmail 6471 invoked from network); 13 Sep 1999 11:27:27 -0000 Date: Mon, 13 Sep 1999 13:27:19 +0200 (MET DST) Message-Id: <199909131127.NAA20862@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Andrej Borsenkow"'s message of Fri, 10 Sep 1999 17:23:08 +0400 Subject: PATCH: Re: Problem with _arguments and invalid options Andrej Borsenkow wrote: > 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 That was really caused by the call to `whence' in `_normal'. > 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 (Your first example behaved in the same way, btw.) Yes, this is intentional: if `_arguments' finds a string that doesn't look like an option to it, it interprets it as the first argument. Hm, I'd like to hear some more comments about this: should we change `_arguments' to (completely) ignore all strings starting with `-' it doesn't know? Might be wrong for some commands. And there is the problem that `_arguments' can handle options starting with `+' and we probably don't want it to skip over all strings starting with a plus sign. Hm. We could make `_arguments' support an option that gives a pattern and make it ignore all strings on the line matching that pattern. But how would we decide if we should use the option for a particular command or not? Bye Sven diff -u oldcompletion/Core/_normal Completion/Core/_normal --- oldcompletion/Core/_normal Mon Sep 13 13:13:15 1999 +++ Completion/Core/_normal Mon Sep 13 13:18:18 1999 @@ -30,7 +30,7 @@ if zmodload -e parameter; then cmd2="$commands[$command]" else - cmd2=$(whence -p $command) + cmd2=$(whence -p - $command) fi fi -- Sven Wischnowsky wischnow@informatik.hu-berlin.de