mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-25 01:28:50 -05:00
Auxiliary: Bash-comp: use _init_completion instead of _split_longopt
Using `_init_completion -s` will handle the option splitting and set the `split` var [1]. Keep setting `split` manually for the older manual bash completion initialization. [1] https://github.com/scop/bash-completion/blob/main/bash_completion.d/000_bash_completion_compat.bash#L227
This commit is contained in:
@@ -2,14 +2,18 @@
|
|||||||
|
|
||||||
_cmake()
|
_cmake()
|
||||||
{
|
{
|
||||||
local cur prev words cword split=false
|
local is_old_completion=false
|
||||||
|
|
||||||
|
local cur prev words cword split
|
||||||
if type -t _init_completion >/dev/null; then
|
if type -t _init_completion >/dev/null; then
|
||||||
_init_completion -n = || return
|
_init_completion -s || return
|
||||||
else
|
else
|
||||||
# manual initialization for older bash completion versions
|
# manual initialization for older bash completion versions
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
is_old_completion=true
|
||||||
|
split=false
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Workaround for options like -DCMAKE_BUILD_TYPE=Release
|
# Workaround for options like -DCMAKE_BUILD_TYPE=Release
|
||||||
@@ -89,7 +93,9 @@ _cmake()
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
_split_longopt && split=true
|
if $is_old_completion; then
|
||||||
|
_split_longopt && split=true
|
||||||
|
fi
|
||||||
|
|
||||||
case "$prev" in
|
case "$prev" in
|
||||||
-C|-P|--graphviz|--system-information)
|
-C|-P|--graphviz|--system-information)
|
||||||
|
|||||||
Reference in New Issue
Block a user