r306258 - [bash-autocompletion] Delete space after flags which has '=' prefix
Yuka Takahashi via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 25 17:35:36 PDT 2017
Author: yamaguchi
Date: Sun Jun 25 17:35:36 2017
New Revision: 306258
URL: http://llvm.org/viewvc/llvm-project?rev=306258&view=rev
Log:
[bash-autocompletion] Delete space after flags which has '=' prefix
Summary:
This is patch for bash completion for clang project.
We don't need space when completing options like "-stdlib=".
Differential Revision: https://reviews.llvm.org/D34594
Modified:
cfe/trunk/utils/bash-autocomplete.sh
Modified: cfe/trunk/utils/bash-autocomplete.sh
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/bash-autocomplete.sh?rev=306258&r1=306257&r2=306258&view=diff
==============================================================================
--- cfe/trunk/utils/bash-autocomplete.sh (original)
+++ cfe/trunk/utils/bash-autocomplete.sh Sun Jun 25 17:35:36 2017
@@ -22,16 +22,17 @@ _clang()
elif [[ "$w2" == -* && "$w1" == '=' ]]; then
# -foo=bar<tab>
arg="$w2=,$cur"
- else
- _filedir
fi
local flags=$( clang --autocomplete="$arg" )
- if [[ "$cur" == "=" ]]; then
+ if [[ "$cur" == '=' ]]; then
COMPREPLY=( $( compgen -W "$flags" -- "") )
- elif [[ "$flags" == "" ]]; then
+ elif [[ "$flags" == "" || "$arg" == "" ]]; then
_filedir
else
+ # Bash automatically appends a space after '=' by default.
+ # Disable it so that it works nicely for options in the form of -foo=bar.
+ [[ "${flags: -1}" == '=' ]] && compopt -o nospace
COMPREPLY=( $( compgen -W "$flags" -- "$cur" ) )
fi
}
More information about the cfe-commits
mailing list