From d03b4acaa9b49c279f8ef7d39173a5dda7d0358f Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 2 Jun 2024 16:56:22 +0300 Subject: 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 --- Auxiliary/bash-completion/cmake | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Auxiliary/bash-completion/cmake b/Auxiliary/bash-completion/cmake index bed7248..e673894 100644 --- a/Auxiliary/bash-completion/cmake +++ b/Auxiliary/bash-completion/cmake @@ -2,14 +2,18 @@ _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 - _init_completion -n = || return + _init_completion -s || return else # manual initialization for older bash completion versions COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" + is_old_completion=true + split=false fi # Workaround for options like -DCMAKE_BUILD_TYPE=Release @@ -89,7 +93,9 @@ _cmake() ;; esac - _split_longopt && split=true + if $is_old_completion; then + _split_longopt && split=true + fi case "$prev" in -C|-P|--graphviz|--system-information) -- cgit v0.12 From 1ff41ba26ef0c22c063ebfd3a80ec91e897db3d2 Mon Sep 17 00:00:00 2001 From: Ahmad Samir Date: Sun, 2 Jun 2024 17:18:00 +0300 Subject: Auxiliary: bash-completion: use _comp_initialize _init_completion has been deprecated upstream since 2.12. https://github.com/scop/bash-completion/blob/main/bash_completion.d/000_bash_completion_compat.bash#L237 --- Auxiliary/bash-completion/cmake | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Auxiliary/bash-completion/cmake b/Auxiliary/bash-completion/cmake index e673894..803e09e 100644 --- a/Auxiliary/bash-completion/cmake +++ b/Auxiliary/bash-completion/cmake @@ -3,10 +3,14 @@ _cmake() { local is_old_completion=false + local is_init_completion=false - local cur prev words cword split - if type -t _init_completion >/dev/null; then + local cur prev words cword split was_split + if type -t _comp_initialize >/dev/null; then + _comp_initialize -s || return + elif type -t _init_completion >/dev/null; then _init_completion -s || return + is_init_completion=true else # manual initialization for older bash completion versions COMPREPLY=() @@ -193,7 +197,11 @@ _cmake() ;; esac - $split && return + if ($is_old_completion || $is_init_completion); then + $split && return + else + [[ $was_split ]] && return + fi if [[ "$cur" == -* ]]; then COMPREPLY=( $(compgen -W '$( _parse_help "$1" --help )' -- ${cur}) ) -- cgit v0.12