From bdc721aac2830be4a7b40e82c1bc93a825a66641 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Tue, 3 Dec 2024 15:47:02 -0500 Subject: [PATCH] fix bugs i dunno how I lived with these for so long --- src/identify-distros | 2 +- src/package-manager-abstractions | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/identify-distros b/src/identify-distros index c275db6..80bb39c 100644 --- a/src/identify-distros +++ b/src/identify-distros @@ -144,7 +144,7 @@ debian-codename() { local policy policy="$(apt-cache policy)" archive=$(debian-archive "$policy") - printf "%s\n" "$policy" | sed -rn "s/^.*a=$archive,n=([a-z]+).*/\1/p;T;q" || [[ $? == 141 ]] + sed -rn "s/^.*a=$archive,n=([a-z]+).*/\1/p;T;q" <<<"$policy" } debian-codename-compat() { local n diff --git a/src/package-manager-abstractions b/src/package-manager-abstractions index 8b7989b..a765967 100644 --- a/src/package-manager-abstractions +++ b/src/package-manager-abstractions @@ -68,7 +68,9 @@ elif command -v apt-get &>/dev/null; then fi done } + # returns 1 if $@ are all already installed packages. pcheck() { + local arg count for arg; do if [[ $1 == -* ]]; then shift @@ -76,8 +78,10 @@ elif command -v apt-get &>/dev/null; then break fi done - if dpkg -s -- "$@" |& grep -Fx "Status: install ok installed" &>/dev/null; then - return 1 + if count=$(dpkg -s -- "$@" 2>/dev/null | grep -cFx "Status: install ok installed"); then + if [[ $count == "$#" ]]; then + return 1 + fi fi return 0 } @@ -119,7 +123,7 @@ elif command -v apt-get &>/dev/null; then fi fi done - if (( cachetime > limittime )); then + if (( cachetime < limittime )); then $s apt-get update fi } -- 2.30.2