From 3138fa9e16edb1b0a3c07872815ce68b11c0e154 Mon Sep 17 00:00:00 2001 From: Jaroslav Rohel Date: Tue, 9 Apr 2024 13:24:30 +0200 Subject: [PATCH] dnf5: bash completion: Prefer using "_comp_initialize" with fallback - ` _comp_initialize` was added in bash-completion 2.12 - `_init_completion` is deprecated since bash-completion 2.12 --- dnf5/bash-completion/dnf5 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/dnf5/bash-completion/dnf5 b/dnf5/bash-completion/dnf5 index 95419e5ab..de2745499 100644 --- a/dnf5/bash-completion/dnf5 +++ b/dnf5/bash-completion/dnf5 @@ -3,7 +3,16 @@ _do_dnf5_completion() { local cur prev words cword comp_args - _init_completion -n "><=;|&(:" -- "$@" || return + + # Test if bash-completion supports "_comp_initialize" (added in bash-completion 2.12) + type _comp_initialize >/dev/null 2>&1 + if [[ $? -eq 0 ]]; then + _comp_initialize -n "><=;|&(:" -- "$@" || return + else + # legacy function call (deprecated since bash-completion 2.12) + _init_completion -n "><=;|&(:" -- "$@" || return + fi + mapfile -t COMPREPLY <<<$("${1}" "--complete=${cword}" "${words[@]}") }