mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-23 17:01:05 +02:00
59 lines
1.4 KiB
Text
59 lines
1.4 KiB
Text
#autoload
|
|
|
|
local opts opt type=file group
|
|
|
|
opts=()
|
|
group=()
|
|
while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:12n" opt; do
|
|
case "$opt" in
|
|
/) [[ "$type" = file ]] && type=dir ;;
|
|
g) [[ "$type" = (file|dir) ]] && type="$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
|
|
file) _tags all-files ;;
|
|
dir) _tags directories all-files ;;
|
|
*) _tags globbed-files directories 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 "$type" && 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
|
|
_path_files "$opts[@]" -g "$type" && return 0
|
|
fi
|
|
done
|
|
|
|
return 1
|