about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Completion/BSD/Command/_bsd_pkg50
-rw-r--r--Completion/Unix/Command/_chown16
3 files changed, 44 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 2c4d2f6c4..8674e0229 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2002-03-25  Oliver Kiddle  <opk@zsh.org>
 
+	* 16396: Completion/Unix/Command/_chown: fix argument handling bugs
+
+	* Akinori Musha: 16534: Completion/BSD/Command/_bsd_pkg:
+	a few bug fixes and some wording fixes
+
 	* users/4561: Completion/Unix/Command/_zip: fix bug with finding
 	the zipfile's name in the current command-line.
 
diff --git a/Completion/BSD/Command/_bsd_pkg b/Completion/BSD/Command/_bsd_pkg
index 26c722886..c8bd6d6d5 100644
--- a/Completion/BSD/Command/_bsd_pkg
+++ b/Completion/BSD/Command/_bsd_pkg
@@ -1,34 +1,41 @@
 #compdef pkg_add pkg_delete pkg_info
 
-(( $+functions[_bsd_pkg_packages] )) ||
-_bsd_pkg_packages() {
-  local ret=1 paths portsdir
+(( $+functions[_bsd_pkg_pkgfiles] )) ||
+_bsd_pkg_pkgfiles() {
+  local ret=1 paths portsdir pkgsdir
 
   case $OSTYPE in
   netbsd*)
-    portsdir=/usr/pkg
+    portsdir=/usr/pkgsrc
     ;;
   *)
     portsdir=${PORTSDIR:-/usr/ports}
     ;;
   esac
 
+  pkgsdir=${PACKAGES:-$portsdir/packages}/All
+
   paths=( "${(@)${(@s.:.)PKG_PATH}:#}" )
   _files "$@" -g \*.tgz && ret=0
   (( $#path )) && _files "$@" -W paths -g \*.tgz && ret=0
-  compadd "$@" - $portsdir/packages/All/*.tgz && ret=0
+  compadd "$@" - $pkgsdir/*.tgz && ret=0
 
   return ret
 }
 
-(( $+functions[_bsd_pkg_or_file] )) ||
-_bsd_pkg_or_file() {
+(( $+functions[_bsd_pkg_pkgs] )) ||
+_bsd_pkg_pkgs() {
+  compadd "$@" - ${PKG_DBDIR:-/var/db/pkg}/*(/:t)
+}
+
+(( $+functions[_bsd_pkg_pkgs_and_files] )) ||
+_bsd_pkg_pkgs_and_files() {
   local ret=1
 
   if (( $words[(I)-*F*] )); then
     _files "$@" && ret=0
   else
-    compadd "$@" - ${PKGDBDIR:-/var/db/pkg}/*(/:t) && ret=0
+    _bsd_pkg_pkgs "$@" && ret=0
   fi
 
   return ret
@@ -44,10 +51,10 @@ _bsd_pkg() {
       '-I[don'\''t execute installation scripts]'
       '-M[run in master mode]'
       '-n[don'\''t really install packages]'
-      '-p:prefix directory:_files -/'
+      '-p[specify prefix]:prefix directory:_files -/'
       '-R[don'\''t record]'
       '-S[run in slave mode]'
-      '-t:mktemp template:_files -/'
+      '-t[specify mktemp template]:mktemp template:_files -/'
       '-v[be verbose]'
     )
 
@@ -55,7 +62,7 @@ _bsd_pkg() {
     freebsd*)
       flags=(
         $flags[@]
-        '-r[use remote fetching]'
+        '-r[fetch from remote site]'
       )
       ;;
     netbsd*)
@@ -69,7 +76,7 @@ _bsd_pkg() {
 
     _arguments -s \
       $flags[@] \
-      '*:package to install:_bsd_pkg_packages'
+      '*:package to install:_bsd_pkg_pkgfiles'
     ;;
 
   pkg_delete)
@@ -78,7 +85,7 @@ _bsd_pkg() {
       '-d[remove empty directories]'
       '-f[force deinstallation]'
       '-n[don'\''t really deinstall packages]'
-      '-p:prefix directory:_files -/'
+      '-p[specify prefix]:prefix directory:_files -/'
       '-v[be verbose]'
     )
 
@@ -86,16 +93,17 @@ _bsd_pkg() {
     freebsd*)
       flags=(
         $flags[@]
-	'(:)-a[show all installed packages]'
+	'(:)-a[delete all installed packages]'
         '-G[do not expand glob patterns]'
 	'-i[be interactive]'
+        '-r[delete recursively]'
         '-x[use regular expression]'
       )
       ;;
     netbsd*)
       flags=(
 	$flags[@]
-	'(:)-a[show all installed packages]'
+	'(:)-a[delete all installed packages]'
 	'-F[specify each package by an installed file]'
 	'-i[be interactive]'
 	'-O[only delete the package'\''s entries]'
@@ -108,7 +116,7 @@ _bsd_pkg() {
 
     _arguments -s \
       $flags[@] \
-      '(-a)*:package name:_bsd_pkg_or_file'
+      '(-a)*:package name:_bsd_pkg_pkgs_and_files'
     ;;
 
   pkg_info)
@@ -117,13 +125,13 @@ _bsd_pkg() {
       '-c[show comment fields]'
       '-D[show install-message files]'
       '-d[show long descriptions]'
-      '-e[test if package is installed]:package name:compadd - ${PKG_DBDIR:-/var/db/pkg}/*(\:t)'
+      '-e[test if package is installed]:package name:_bsd_pkg_pkgs'
       '-f[show packing list instructions]'
       '-I[show index lines]'
       '-i[show install scripts]'
       '-k[show deinstall scripts]'
       '-L[show full pathnames of files]'
-      '-l:prefix directory:_files -/'
+      '-l[specify prefix string]:prefix string:'
       '-m[show mtree files]'
       '-p[show installation prefixes]'
       '-q[be quiet]'
@@ -140,8 +148,8 @@ _bsd_pkg() {
 	'-g[show files that'\''s modified]'
 	'-o[show origin]'
 	'-s[show total size occupied by each package]'
-	'-t:mktemp template:_files -/'
-	'*-W:show which package the file belongs to:_files'
+	'-t[specify mktemp template]:mktemp template:_files -/'
+	'*-W[show which package the file belongs to]:file:_files'
 	'-x[use regular expression]'
       )
       ;;
@@ -160,7 +168,7 @@ _bsd_pkg() {
 
     _arguments -s \
       $flags[@] \
-      '(-a)*:package name:_bsd_pkg_or_file'
+      '(-a)*:package name:_bsd_pkg_pkgs_and_files'
     ;;
   esac
 }
diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown
index f5ff8f45e..599e09d14 100644
--- a/Completion/Unix/Command/_chown
+++ b/Completion/Unix/Command/_chown
@@ -1,8 +1,12 @@
 #compdef chown chgrp
 
-local suf usr grp req expl
+local suf usr grp req expl line
 
-if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then
+line=( "${(@)words[2,CURRENT-1]:#-*}" )
+
+if [[ -prefix - ]]; then
+  _message -e options option
+elif [[ $#line -eq 0 ]]; then
   if [[ $service = chgrp ]] || compset -P '*[:.]'; then
     if (( EGID && $+commands[groups] )); then  # except for root
       _wanted groups expl 'group' compadd $(groups) && return 0
@@ -19,16 +23,16 @@ if [[ CURRENT -eq 2 || CURRENT -eq 3 && $words[CURRENT-1] = -* ]]; then
   fi
 else
   if [[ $service = chgrp ]]; then
-    grp=${words[CURRENT-1]}
+    grp=${line[1]}
   else
-    usr=${words[CURRENT-1]%%[.:]*}
+    usr=${line[1]%%[.:]*}
     usr=${${(M)usr:#[0-9]#}:-${userdirs[$usr]:+.$usr.}}
-    grp=${${(M)words[CURRENT-1]%%[.:]*}#?}
+    grp=${${(M)line[1]%%[.:]*}#?}
   fi
   [[ -n $grp ]] && grp="${${(M)grp:#[0-9]#}:-.$grp.}"
   req=( ${usr:+\^u$usr} ${grp:+\^g$grp} )
   (( EUID )) && req=( u$EUID$^req )
   req=( -$^req )
 
-  _files -g "*(${(j:,:)req})" && return 0
+  _wanted files expl file _files -g "*(${(j:,:)req})" && return 0
 fi