Skip to content

Commit

Permalink
bash-completion: Complete dnf command only if we own it
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-kolarik authored and ppisar committed Mar 28, 2024
1 parent b7e4766 commit 75803f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions dnf.spec
Expand Up @@ -84,6 +84,7 @@ BuildRequires: bash-completion-devel
%else
BuildRequires: bash-completion
%endif
Requires: coreutils
BuildRequires: %{_bindir}/sphinx-build-3
Requires: python3-%{name} = %{version}-%{release}
%if 0%{?rhel} && 0%{?rhel} <= 7
Expand Down
9 changes: 8 additions & 1 deletion etc/bash_completion.d/dnf
Expand Up @@ -433,4 +433,11 @@ _dnf()
return 0
}

complete -F _dnf dnf dnf-2 dnf-3
complete_cmds="dnf-2 dnf-3 dnf4"
dnf_target=$(readlink -f "/usr/bin/dnf")

if [ "$dnf_target" = "/usr/bin/dnf-3" ]; then
complete_cmds+=" dnf"
fi

complete -F _dnf $complete_cmds

0 comments on commit 75803f5

Please sign in to comment.