1999-07-19 16:26:17 +02:00
|
|
|
#compdef su
|
|
|
|
|
|
|
|
local shell comp name usr base
|
|
|
|
|
|
|
|
[[ $words[2] != - ]]
|
|
|
|
(( base=$?+2 ))
|
|
|
|
|
|
|
|
if [[ CURRENT -eq base ]]; then
|
2000-05-19 18:19:39 +02:00
|
|
|
_users && return
|
1999-07-19 16:26:17 +02:00
|
|
|
usr=root
|
|
|
|
elif [[ CURRENT -ge base+1 ]]; then
|
|
|
|
usr=$words[base]
|
|
|
|
else
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
2000-05-19 18:19:39 +02:00
|
|
|
shell="${${(M@)${(@f)$(</etc/passwd)}:#$usr*}##*:}"
|
1999-07-19 16:26:17 +02:00
|
|
|
compset -n $base
|
|
|
|
for name in $shell $shell:t -default-; do
|
|
|
|
comp="$_comps[$name]"
|
2000-05-19 18:19:39 +02:00
|
|
|
[[ -n "$comp" ]] && "$comp" && return
|
1999-07-19 16:26:17 +02:00
|
|
|
done
|