Skip to content

Commit

Permalink
improve validation for Pkg
Browse files Browse the repository at this point in the history
  • Loading branch information
ogabriel committed Jun 27, 2024
1 parent 6c95d39 commit 342a084
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions lib/config_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,23 @@ function RemovePkg() {
sourced_packages_dir=$config_dir/packages/

function Package() {
if [[ $2 == '--aur' ]] || [[ $2 == '--AUR' ]]; then
if [[ $# -eq 1 ]]; then
case $distro in
arch)
if ! pacman -Q $1 &>/dev/null; then
packages+=($1)
fi
;;
debian)
if ! dpkg -l $1 &>/dev/null; then
packages+=($1)
fi
;;
*)
Error "Could not check if package $1 is installed on $distro"
;;
esac
elif [[ $2 == '--aur' ]] || [[ $2 == '--AUR' ]]; then
ValidateExactFunctionParams 2 $# $FUNCNAME

if [[ $distro == 'arch' ]]; then
Expand Down Expand Up @@ -107,23 +123,7 @@ function Package() {
flatpak_packages+=($1)
fi
else
ValidateFunctionParams 1 $# $FUNCNAME

case $distro in
arch)
if ! pacman -Q $1 &>/dev/null; then
packages+=($1)
fi
;;
debian)
if ! dpkg -l $1 &>/dev/null; then
packages+=($1)
fi
;;
*)
Error "Could not check if package $1 is installed on $distro"
;;
esac
Error "Invalid flag $2 for $FUNCNAME"
fi
}

Expand Down

0 comments on commit 342a084

Please sign in to comment.