From 96de4d0740485b70e8e6210fd47e83c6a9bece0e Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Thu, 3 Jan 2002 12:47:55 +0000 Subject: 16396: fix argument handling bugs --- Completion/Unix/Command/_chown | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'Completion/Unix/Command/_chown') 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 -- cgit 1.4.1