From 10578849c9a7cb1e1323fb98b270349651b5bf90 Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Tue, 15 Oct 2019 17:07:53 -0600 Subject: [PATCH 1/1] LU-12734 misc: allow older bash_completion versions 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 Change-Id: I3822c0967354d83d12f299c4be3023b2fc254035 Reviewed-on: https://review.whamcloud.com/36459 Tested-by: jenkins Reviewed-by: Quentin Bouget Tested-by: Maloo Reviewed-by: Nathaniel Clark Reviewed-by: Dominique Martinet --- lustre/scripts/bash-completion/lctl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lustre/scripts/bash-completion/lctl b/lustre/scripts/bash-completion/lctl index 485bb69..e471e18 100644 --- a/lustre/scripts/bash-completion/lctl +++ b/lustre/scripts/bash-completion/lctl @@ -2,8 +2,15 @@ _lctl() { 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 | -- 1.8.3.1