zsh-workers
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: Problem with _arguments and invalid options
Date: Mon, 13 Sep 1999 13:27:19 +0200 (MET DST)	[thread overview]
Message-ID: <199909131127.NAA20862@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Andrej Borsenkow"'s message of Fri, 10 Sep 1999 17:23:08 +0400


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


                 reply	other threads:[~1999-09-13 11:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=199909131127.NAA20862@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=zsh-workers@sunsite.auc.dk \
    /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).