about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Unix/Command/_chown16
2 files changed, 14 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 2f14e38ee..fb603a5ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2002-01-03  Oliver Kiddle  <opk@zsh.org>
+
+	* 16396: Completion/Unix/Command/_chown: fix argument handling bugs
+
 2002-01-03  Clint Adams  <clint@zsh.org>
 
 	* 16393: Completion/Debian/Command/.distfiles,
diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown
index f5ff8f45e..2e55209c5 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 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