about summary refs log tree commit diff
path: root/Completion/Core/_style
blob: b0cbd7b0024cf49a0c27570cc02349f2d5acaa70 (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#autoload

local tags get i

if [[ "$1" = -g ]]; then
  get=yes
  shift
fi

if (( ${+_cur_tags[${funcstack[2,-1]}]} )); then
  tags="${_cur_tags[${funcstack[2,-1]}]}"
else
  tags="${_cur_tags[${funcstack[3,-1]}]}"
fi

if [[ "$tags" = *:${1}\[*\]:* ]]; then

  tags="${${tags#*:${1}\[}%%\]*}"

  if [[ $# -eq 2 ]]; then
    if [[ -n "$get" ]]; then
      eval "${2}=\"$tags\""
      return 0
    fi

    [[ "$tags" = (|*,)${2}(|,*) ]]
    return
  fi

  [[ "$tags" = (|*,)${2}(|(\=|,)*) ]] || return 1

  if [[ -n "$get" ]]; then
    if [[ "$tags" = (|*,)${2}\=* ]]; then
      eval "${3}=\"${${tags#(|*,)${2}\=}%%,*}\""
    else
      eval "${3}=''"
    fi
    return 0
  fi

  [[ "$tags" = (|*,)${2}\=(|[^,]#,)${3}(|,*) ]] 
  return
fi

return 1