about summary refs log tree commit diff
path: root/Completion/Core/_files
blob: b6349a8c56a61d2de3e776c521d658edef1ed9f1 (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
#autoload

# Utility function for completing files of a given type or any file.
# In many cases you will want to call this one instead of `_path_files'.

local nm=$compstate[nmatches] ret=1

_path_files "$@" && ret=0

if [[ $# -ne 0 && compstate[nmatches] -eq nm ]]; then
  local opt opts

  # We didn't get any matches for those types of files described by
  # the `-g' or `-/' option. Now we try it again accepting all files.
  # First we get those options that we have to use even then. If we
  # find out that the `-f' option was given, we already accepted all
  # files and give up immediatly.

  opts=()
  while getopts "P:S:W:F:J:V:X:f/g:" opt; do
    [[ "$opt" = f ]] && return
    [[ "$opt" = [PSWFJVX] ]] && opts=("$opts[@]" "-$opt" "$OPTARG")
  done

  _path_files "$opts[@]" && ret=0
fi

return ret