3 local cur prev words cword
6 # allow different versions of bash_completion to work
7 if declare -F _init_completion > /dev/null; then
8 # this provides more functionality, but is only in v2.x
9 _init_completion || return
11 # this is compatible with both v1.3 and v2.x
12 _get_comp_words_by_ref -n : cur prev words cword
15 if [[ "$cword" == "1" ]]; then
16 COMPREPLY=( $( compgen -W '$(lctl --list-commands |
17 grep -v '^=')' -- "$cur" ) )
22 set_param|list_param|get_param)
24 [[ "${words[1]}" == "set_param" ]] && filter="/[^=/]$/d"
25 mapfile -t COMPREPLY < <(
26 lctl list_param -F "${cur#[\"\']}*" 2>/dev/null |
27 sed -e "$filter" -e 's#/$#.#' \
28 -e "s#^${cur//\*/[^.]*}#$cur#"
36 complete -F _lctl lctl