fix: assume no pkgs when dir is empty or does not exist

This commit is contained in:
Lily Foster 2023-01-04 09:59:23 -05:00
parent 426a242c94
commit 9a52096c91
No known key found for this signature in database
GPG key ID: 49340081E484C893

View file

@ -1807,7 +1807,7 @@ get_packages() {
has() { type -p "$1" >/dev/null && manager=$1; }
# globbing is intentional here
# shellcheck disable=SC2206
dir() { pkgs=($@); ((packages+=${#pkgs[@]})); pac "$((${#pkgs[@]}-pkgs_h))"; }
dir() { pkgs=($@); [[ ! -e ${pkgs[0]} ]] && return; ((packages+=${#pkgs[@]})); pac "$((${#pkgs[@]}-pkgs_h))"; }
pac() { (($1 > 0)) && { managers+=("$1 (${manager})"); manager_string+="${manager}, "; }; }
tot() {
IFS=$'\n' read -d "" -ra pkgs <<< "$("$@")";