26763: fix problem on failed cd -s to relative path
[zsh.git] / Completion / Zsh / Command / _which
blob07ede39fdb3119325c9ae8bc6ee5b7cbc2dbefd9
1 #compdef which whence where type
3 local farg aarg cargs args state line curcontext="$curcontext" ret=1
5 cargs=( \
6   '(-v -c)-w[print command type]' \
7   '-p[always do a path search]' \
8   '-m[treat the arguments as patterns]' \
9   '-s[print symlink free path as well]' \
10   '*:commands:->command' )
11 farg='-f[output contents of functions]'
12 aarg='-a[print all occurrences in path]'
14 case ${service} in
15   whence)
16     _arguments -C -s -A "-*" -S \
17       '(-c -w)-v[verbose output]' \
18       '(-v -w)-c[csh-like output]' \
19       "${cargs[@]}" "$farg" "$aarg" && ret=0
20   ;;
21   where) _arguments -C -s -A "-*" -S "${cargs[@]}" && ret=0;;
22   which) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" && ret=0;;
23   type) _arguments -C -s -A "-*" -S "${cargs[@]}" "$aarg" "$farg" && ret=0;;
24 esac
26 if [[ "$state" = command ]]; then
28   args=( "$@" )
30   _alternative -O args \
31     'commands:external command:_path_commands' \
32     'builtins:builtin command:compadd -k builtins' \
33     'functions:shell function:compadd -k functions' \
34     'aliases:alias:compadd -k aliases' \
35     'reserved-words:reserved word:compadd -k reswords' && ret=0
39 return ret