#autoload local opts opt type=file tags opts=() while getopts "P:S:qr:R:W:F:J:V:X:f/g:M:" opt; do case "$opt" in /) [[ "$type" = file ]] && type=dir ;; g) [[ "$type" = (file|dir) ]] && type="$OPTARG" ;; q) opts=("$opts[@]" -q ) ;; [^f]) opts=("$opts[@]" "-$opt" "$OPTARG") ;; esac done case "$type" in file) _tags -f "$funcstack[2]" file ;; dir) _tags -f "$funcstack[2]" path file ;; *) _tags -f "$funcstack[2]" glob path file ;; esac while _tags; do [[ "$tags" = *:file:* ]] && { _path_files "$opts[@]" -f ; return } [[ "$tags" = *:path:* ]] && _path_files "$opts[@]" -/ && return 0 [[ "$tags" = *:glob:* ]] && _path_files "$opts[@]" -g "$type" && return 0 done return 1