summary refs log tree commit diff
path: root/Completion/Builtins/_vars
blob: dece0fecbd818c605a5da438acfac89634a7e438 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#compdef getopts unset vared

# This will handle completion of keys of associative arrays, e.g. at
# `vared foo[<TAB>'.

local ret=1

if [[ $PREFIX = *\[* ]]; then
  compstate[parameter]=${PREFIX%%(|\\)\[*}

  IPREFIX=${PREFIX%%\[*}\[
  PREFIX=${PREFIX#*\[}

  _subscript -q
else
  _parameters -g '^a*' "$@" && ret=0
  
  if compset -S '\[*'; then
    set - -S "" "$@"
  else
    set - -qS"${${QIPREFIX:+[}:-\[}" "$@"
  fi
  _parameters -g 'a*' "$@" && ret=0
  return ret
fi