From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4182 invoked from network); 28 May 2000 19:34:22 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 May 2000 19:34:22 -0000 Received: (qmail 5166 invoked by alias); 28 May 2000 19:34:09 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11615 Received: (qmail 5158 invoked from network); 28 May 2000 19:34:08 -0000 Sender: opk Message-ID: <393158CD.C9142475@u.genie.co.uk> Date: Sun, 28 May 2000 18:35:09 +0100 From: Oliver Kiddle X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.2.15 i586) X-Accept-Language: en MIME-Version: 1.0 To: zsh-workers@sunsite.auc.dk Subject: PATCH: use _arguments in _which and _unhash Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Bart Schaefer wrote: > I can reproduce this, but > > } % zpty -w l > } _arguments:shift:297: shift count must be <= $# > > I can't reproduce that. Are you sure? I can reproduce it on different platforms and when starting with zsh -f. Maybe one of your options avoids it. Totally unrelated to this, I've changed a couple more of the completion functions to use _arguments (which and unhash). Oliver --- Completion/Builtins/_unhash Thu Dec 30 18:28:37 1999 +++ Completion/Builtins/_unhash Sun May 28 16:45:29 2000 @@ -1,14 +1,14 @@ #compdef unhash -local fl="$words[2]" args +local expl state line curcontext="$curcontext" -args=() -[[ "$fl" = -*d* ]] && - args=( 'named-directories:named directory:compadd - ${(@k)nameddirs}' ) -[[ "$fl" = -*a* ]] && - args=( "$args[@]" - 'aliases:alias:compadd - ${(@k)aliases} ${(@k)galiases} ${(@k)dis-aliases} ${(@k)dis-galiases}' ) -[[ "$fl" != -* ]] && - args=( 'commands:: _command_names -e' ) +_arguments -C -s \ + '(-a -f *)-d[remove named directories]:*:named directory:->nameddir' \ + '(-d -f *)-a[remove aliases]:*:aliases:_aliases' \ + '(-d -a *)-f[remove functions]:*:functions:_functions' \ + '-m[treat arguments as patterns]' \ + '*:commands:_command_names -e' && return 0 -_alternative "$args[@]" +if [[ "$state" = nameddir ]]; then + _wanted nameddir expl 'named directory' compadd - ${(@k)nameddirs} +fi --- Completion/Builtins/_which.bak Mon Nov 15 12:01:47 1999 +++ Completion/Builtins/_which Sun May 28 15:50:57 2000 @@ -1,6 +1,29 @@ #compdef which whence where type -local args +local farg aarg cargs args state line curcontext="$curcontext" + +cargs=( \ + '(-v -c)-w[print command type]' \ + '-p[always do a path search]' \ + '-m[treat the arguments as patterns]' \ + '-s[print symlink free path as well]' \ + '*:commands:->command' ) +farg='-f[output contents of functions]' +aarg='-a[print all occurences in path]' + +case ${words[1]} in + whence) + _arguments -C -s \ + '(-c -w)-v[verbose output]' \ + '(-v -w)-c[csh-like output]' \ + "${cargs[@]}" "$farg" "$aarg" && return 0 + ;; + where) _arguments -C -s "${cargs[@]}" && return 0;; + which) _arguments -C -s "${cargs[@]}" "$aarg" && return 0;; + type) _arguments -C -s "${cargs[@]}" "$aarg" "$farg" && return 0;; +esac + +if [[ "$state" = command ]]; then args=( "$@" ) @@ -10,3 +33,5 @@ 'functions:shell function:compadd - ${(k@)functions}' \ 'aliases:alias:compadd - ${(k@)aliases}' \ 'reserved-words:reserved word:compadd - ${(k@)reswords}' + +fi