The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

bash completion: fix glued file and directory completions

Close #231, close #244

authored by

Brian Ward and committed by
Daniel Bünzli
4080c6ed 64df5b45

+40 -20
+19 -9
vendor/opam/cmdliner/src/tool/bash-completion.sh
··· 17 17 while read type; do 18 18 if [[ $type == "group" ]]; then 19 19 read group 20 - elif [[ $type == "dirs" ]] && (type compopt &> /dev/null); then 21 - if [[ $prefix != -* ]]; then 22 - compopt -o filenames 23 - COMPREPLY+=( $(compgen -d "$prefix") ) 24 - fi 25 - elif [[ $type == "files" ]] && (type compopt &> /dev/null); then 26 - if [[ $prefix != -* ]]; then 27 - compopt -o filenames 28 - COMPREPLY+=( $(compgen -f "$prefix") ) 20 + elif [[ $type == "dirs" || $type == "files" ]] && (type compopt &> /dev/null); then 21 + # trim option prefix in cases like --file=<TAB> or -f<TAB> 22 + local pattern="$prefix" 23 + local reply_prefix="" 24 + if [[ $pattern == --* ]]; then 25 + pattern="${prefix#*=}" 26 + elif [[ $pattern == -* ]]; then 27 + pattern="${prefix:2}" 28 + reply_prefix="${prefix:0:2}" 29 29 fi 30 + 31 + # enable filename completion features like trailing slash for dirs 32 + compopt -o filenames -o nospace 33 + 34 + # need to run compgen with -d or -f flag 35 + local flag="${type:0:1}" 36 + local completions=( $(compgen -$flag "$pattern") ) 37 + for c in "${completions[@]}"; do 38 + COMPREPLY+=("${reply_prefix}${c}") 39 + done 30 40 elif [[ $type == "message" ]]; then 31 41 msg=""; 32 42 while read text_line; do
+21 -11
vendor/opam/cmdliner/src/tool/cmdliner_data.ml
··· 1 1 let strf = Printf.sprintf 2 2 3 - let bash_generic_completion fun_name = strf 3 + let bash_generic_completion fun_name = strf 4 4 {|%s() { 5 5 local words cword 6 6 # Equivalent of COMP_WORDS, COMP_CWORD but allow us to exclude '=' as a word separator ··· 20 20 while read type; do 21 21 if [[ $type == "group" ]]; then 22 22 read group 23 - elif [[ $type == "dirs" ]] && (type compopt &> /dev/null); then 24 - if [[ $prefix != -* ]]; then 25 - compopt -o filenames 26 - COMPREPLY+=( $(compgen -d "$prefix") ) 27 - fi 28 - elif [[ $type == "files" ]] && (type compopt &> /dev/null); then 29 - if [[ $prefix != -* ]]; then 30 - compopt -o filenames 31 - COMPREPLY+=( $(compgen -f "$prefix") ) 23 + elif [[ $type == "dirs" || $type == "files" ]] && (type compopt &> /dev/null); then 24 + # trim option prefix in cases like --file=<TAB> or -f<TAB> 25 + local pattern="$prefix" 26 + local reply_prefix="" 27 + if [[ $pattern == --* ]]; then 28 + pattern="${prefix#*=}" 29 + elif [[ $pattern == -* ]]; then 30 + pattern="${prefix:2}" 31 + reply_prefix="${prefix:0:2}" 32 32 fi 33 + 34 + # enable filename completion features like trailing slash for dirs 35 + compopt -o filenames -o nospace 36 + 37 + # need to run compgen with -d or -f flag 38 + local flag="${type:0:1}" 39 + local completions=( $(compgen -$flag "$pattern") ) 40 + for c in "${completions[@]}"; do 41 + COMPREPLY+=("${reply_prefix}${c}") 42 + done 33 43 elif [[ $type == "message" ]]; then 34 44 msg=""; 35 45 while read text_line; do ··· 71 81 } 72 82 |} fun_name 73 83 74 - let zsh_generic_completion fun_name = strf 84 + let zsh_generic_completion fun_name = strf 75 85 {|function %s { 76 86 local w=("${words[@]}") # Keep words intact for restart completion 77 87 local prefix="${words[CURRENT]}"