fix bugs i dunno how I lived with these for so long master
authorIan Kelling <iank@fsf.org>
Tue, 3 Dec 2024 20:47:02 +0000 (15:47 -0500)
committerIan Kelling <iank@fsf.org>
Tue, 3 Dec 2024 20:47:02 +0000 (15:47 -0500)
src/identify-distros
src/package-manager-abstractions

index c275db60adc72594ce005d7a03280a51311daa6d..80bb39c0e8ed3be5e7a1acaa51119435cb58a08e 100644 (file)
@@ -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
index 8b7989b0012e60c3bd6609558b99d914ba7250fc..a765967c595abbe55292bad465529b7d9de4f4e2 100644 (file)
@@ -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
   }