···1717 while read type; do
1818 if [[ $type == "group" ]]; then
1919 read group
2020- elif [[ $type == "dirs" ]] && (type compopt &> /dev/null); then
2121- if [[ $prefix != -* ]]; then
2222- compopt -o filenames
2323- COMPREPLY+=( $(compgen -d "$prefix") )
2424- fi
2525- elif [[ $type == "files" ]] && (type compopt &> /dev/null); then
2626- if [[ $prefix != -* ]]; then
2727- compopt -o filenames
2828- COMPREPLY+=( $(compgen -f "$prefix") )
2020+ elif [[ $type == "dirs" || $type == "files" ]] && (type compopt &> /dev/null); then
2121+ # trim option prefix in cases like --file=<TAB> or -f<TAB>
2222+ local pattern="$prefix"
2323+ local reply_prefix=""
2424+ if [[ $pattern == --* ]]; then
2525+ pattern="${prefix#*=}"
2626+ elif [[ $pattern == -* ]]; then
2727+ pattern="${prefix:2}"
2828+ reply_prefix="${prefix:0:2}"
2929 fi
3030+3131+ # enable filename completion features like trailing slash for dirs
3232+ compopt -o filenames -o nospace
3333+3434+ # need to run compgen with -d or -f flag
3535+ local flag="${type:0:1}"
3636+ local completions=( $(compgen -$flag "$pattern") )
3737+ for c in "${completions[@]}"; do
3838+ COMPREPLY+=("${reply_prefix}${c}")
3939+ done
3040 elif [[ $type == "message" ]]; then
3141 msg="";
3242 while read text_line; do
+21-11
vendor/opam/cmdliner/src/tool/cmdliner_data.ml
···11let strf = Printf.sprintf
2233-let bash_generic_completion fun_name = strf
33+let bash_generic_completion fun_name = strf
44{|%s() {
55 local words cword
66 # Equivalent of COMP_WORDS, COMP_CWORD but allow us to exclude '=' as a word separator
···2020 while read type; do
2121 if [[ $type == "group" ]]; then
2222 read group
2323- elif [[ $type == "dirs" ]] && (type compopt &> /dev/null); then
2424- if [[ $prefix != -* ]]; then
2525- compopt -o filenames
2626- COMPREPLY+=( $(compgen -d "$prefix") )
2727- fi
2828- elif [[ $type == "files" ]] && (type compopt &> /dev/null); then
2929- if [[ $prefix != -* ]]; then
3030- compopt -o filenames
3131- COMPREPLY+=( $(compgen -f "$prefix") )
2323+ elif [[ $type == "dirs" || $type == "files" ]] && (type compopt &> /dev/null); then
2424+ # trim option prefix in cases like --file=<TAB> or -f<TAB>
2525+ local pattern="$prefix"
2626+ local reply_prefix=""
2727+ if [[ $pattern == --* ]]; then
2828+ pattern="${prefix#*=}"
2929+ elif [[ $pattern == -* ]]; then
3030+ pattern="${prefix:2}"
3131+ reply_prefix="${prefix:0:2}"
3232 fi
3333+3434+ # enable filename completion features like trailing slash for dirs
3535+ compopt -o filenames -o nospace
3636+3737+ # need to run compgen with -d or -f flag
3838+ local flag="${type:0:1}"
3939+ local completions=( $(compgen -$flag "$pattern") )
4040+ for c in "${completions[@]}"; do
4141+ COMPREPLY+=("${reply_prefix}${c}")
4242+ done
3343 elif [[ $type == "message" ]]; then
3444 msg="";
3545 while read text_line; do
···7181}
7282|} fun_name
73837474-let zsh_generic_completion fun_name = strf
8484+let zsh_generic_completion fun_name = strf
7585{|function %s {
7686 local w=("${words[@]}") # Keep words intact for restart completion
7787 local prefix="${words[CURRENT]}"