Skip to content

Commit

Permalink
Remove and rename global variables in bash completion
Browse files Browse the repository at this point in the history
To make sure there is no collision with global variables in other
scripts, the global variable "dnf_target" was removed and
"complete_cmds" was renamed to "_complete_dnf5_cmds".
  • Loading branch information
jrohel committed Jan 3, 2025
1 parent 8751434 commit 4bc604d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions dnf5/bash-completion/dnf5
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ _do_dnf5_completion()
mapfile -t COMPREPLY <<<$("${1}" "--complete=${cword}" "${words[@]}")
}

complete_cmds="dnf5"
dnf_target=$(readlink -f "/usr/bin/dnf")

if [ "$dnf_target" = "/usr/bin/dnf5" ]; then
complete_cmds+=" dnf"
_complete_dnf5_cmds="dnf5"
if [ "$(readlink -fn /usr/bin/dnf)" = "/usr/bin/dnf5" ]; then
_complete_dnf5_cmds+=" dnf"
fi

complete -F _do_dnf5_completion -o nosort -o nospace $complete_cmds
complete -F _do_dnf5_completion -o nosort -o nospace $_complete_dnf5_cmds

0 comments on commit 4bc604d

Please sign in to comment.