about summary refs log tree commit diff
path: root/Completion/Unix/Type/_perl_builtin_funcs
blob: 1c01a0dd695849604bef95145ec29c3354069880 (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
#autoload
#
# Parses perlfunc(1) to get a list of perl functions. The result is cached
# for future use.

if (( ! $+_perl_builtin_funcs )); then
  typeset -agU _perl_builtin_funcs
  local perlfunc

  if [[ -n "${perlfunc:=$(man -w perlfunc 2>/dev/null; print -l ${^manpath:-${(s.:.)$(manpath)}}/man1/perlfunc.1(|[zZ]|gz|bz2)(N) {/usr/man,/usr/share/man,/usr/local/man}/man1/perlfunc.1(|[zZ]|gz|bz2)(N))}" ]]; then
    case $perlfunc in
      *.bz2) perlfunc="bzip2 -cd $perlfunc" ;;
      *[zZ]) perlfunc="gzip -cd $perlfunc" ;;
      *) perlfunc="cat $perlfunc" ;;
    esac
    _perl_builtin_funcs=(
      $($=perlfunc | perl -lne '
      $in_funcs++, next if /Alphabetical/;
      next unless $in_funcs;
      if (/^\.I[pP] "(\w+)/) {
        print $1 unless $func{$1}; $func{$1}++
      }')
    )
  else
    _message "can't find perlfunc man page; giving up"
    return 1
  fi
fi

local expl

_wanted functions expl 'perl built-in function' compadd "$@" -a - \
    _perl_builtin_funcs