blob: f3eb0e5fc0ad188ee069dd6fa209fcc428143f4c (
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#autoload
local opts opt type=file glob group
opts=()
group=()
while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:12n" opt; do
case "$opt" in
/) type="${type}dir" ;;
g) type="${type}glob"; glob="$OPTARG" ;;
[qn12]) opts=("$opts[@]" "-$opt" ) ;;
[JV]) group=( "-$opt" "$OPTARG") ;;
[^f]) opts=("$opts[@]" "-$opt" "$OPTARG") ;;
esac
done
if [[ "$group[2]" = files ]]; then
opts=("$opts[@]" "$group[@]")
group=()
fi
case "$type" in
*dir*glob*|*glob*dir) _tags globbed-files all-files ;;
*glob*) _tags globbed-files directories all-files ;;
*dir*) _tags directories all-files ;;
*) _tags all-files ;;
esac
while _tags; do
if _requested all-files; then
if (( $#group )); then
group[2]=all-files
_setup all-files
fi
_path_files "$opts[@]" -f
return
elif _requested directories; then
if _requested globbed-files; then
if (( $#group )); then
group[2]=globbed-files
_setup globbed-files
fi
_path_files "$opts[@]" -/g "$glob" && return 0
else
if (( $#group )); then
group[2]=directories
_setup directories
fi
_path_files "$opts[@]" -/ && return 0
fi
elif _requested globbed-files; then
if (( $#group )); then
group[2]=globbed-files
_setup globbed-files
fi
if [[ "$type" = (*dir*glob*|*glob*dir*) ]]; then
_path_files "$opts[@]" -/g "$glob" && return 0
else
_path_files "$opts[@]" -g "$glob" && return 0
fi
fi
done
return 1
|