26763: fix problem on failed cd -s to relative path
[zsh.git] / Completion / Unix / Type / _dir_list
blob536d424e3e701c7618ef598b85d93561b93507e9
1 #compdef -value-,TERMINFO_DIRS,-default- -P -value-,*PATH,-default-
3 # options:
4 #  -s <sep> to specify the separator (default is a colon)
5 #  -S       to say that the separator should be added as a suffix (instead
6 #           of the default slash)
7 # any description passed should apply to an individual directory and not
8 # to the entire list
10 local sep=: dosuf suf
12 while [[ "$1" = -(s*|S) ]]; do
13   case "$1" in
14   -s)  sep="$2"; shift 2;;
15   -s*) sep="${1[3,-1]}"; shift;;
16   -S)  dosuf=yes; shift;;
17   esac
18 done
20 compset -P "*${sep}"
21 compset -S "${sep}*" || suf="$sep"
23 if [[ -n "$dosuf" ]]; then
24   suf=(-S "$suf")
25 else
26   suf=()
29 _directories "$suf[@]" -r "${sep}"' /\t\t\-' "$@"