summaryrefslogtreecommitdiff
path: root/3138fa9e16edb1b0a3c07872815ce68b11c0e154.patch
blob: ef8b3c77b29c7d7e26322da22b7e3117d11db66e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
From 3138fa9e16edb1b0a3c07872815ce68b11c0e154 Mon Sep 17 00:00:00 2001
From: Jaroslav Rohel <jrohel@redhat.com>
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[@]}")
 }