Allow the "lctl" bash_completion to work on older versions which
which don't have _init_completions(). Check at runtime if this
function is available, and if not fall back to an older interface.
Has been manually tested with both bash-completion v1.3 and v2.1.
Fixes:
f87a7f2656ce ("LU-12734 misc: add bash completion for lctl set/get_param)"
Test-Parameters: trivial
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I3822c0967354d83d12f299c4be3023b2fc254035
Reviewed-on: https://review.whamcloud.com/36459
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Nathaniel Clark <nclark@whamcloud.com>
Reviewed-by: Dominique Martinet <dominique.martinet@cea.fr>
{
local cur prev words cword
- _init_completion || return
COMPREPLY=()
+ # allow different versions of bash_completion to work
+ if declare -F _init_completion > /dev/null; then
+ # this provides more functionality, but is only in v2.x
+ _init_completion || return
+ else
+ # this is compatible with both v1.3 and v2.x
+ _get_comp_words_by_ref -n : cur prev words cword
+ fi
if [[ "$cword" == "1" ]]; then
COMPREPLY=( $( compgen -W '$(lctl --list-commands |