From c893bf0dd763f161048ab2ce0ded2a36dfcc0a7f Mon Sep 17 00:00:00 2001 From: theofficialgman <28281419+theofficialgman@users.noreply.github.com> Date: Sat, 24 Feb 2024 20:10:29 -0500 Subject: [PATCH] api: `anything_installed_from_uri_suite_component` simplify function --- api | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/api b/api index 07b8d43415..baf2ac1aba 100755 --- a/api +++ b/api @@ -241,7 +241,6 @@ anything_installed_from_uri_suite_component() { #Given an apt repository uri, su debug "$repofiles" #for every repo-file, check if any of them have an installed file - local found=0 local IFS=$'\n' local repofile for repofile in $repofiles ;do @@ -252,24 +251,12 @@ anything_installed_from_uri_suite_component() { #Given an apt repository uri, su local apt_cache_policy_output="$(echo "$packages_in_repo" | list_intersect "$installed_packages" | tr '\n' ' ' | xargs -r apt-cache policy)" if [ -z "$3" ]; then - if echo "$apt_cache_policy_output" | grep -B1 "$(echo "$1" | sed 's+.*://++g' | sed "s,/$,,") $2" | awk '{print $1}' | grep -Fq '***' ;then - found=1 - break - fi + echo "$apt_cache_policy_output" | grep -B1 "$(echo "$1" | sed 's+.*://++g' | sed "s,/$,,") $2" | awk '{print $1}' | grep -Fq '***' && return 0 else - if echo "$apt_cache_policy_output" | grep -B1 "$(echo "$1" | sed 's+.*://++g' | sed "s,/$,,") $2/$3" | awk '{print $1}' | grep -Fq '***' ;then - found=1 - break - fi + echo "$apt_cache_policy_output" | grep -B1 "$(echo "$1" | sed 's+.*://++g' | sed "s,/$,,") $2/$3" | awk '{print $1}' | grep -Fq '***' && return 0 fi done - - #return an exit code - if [ $found == 1 ];then - return 0 - else - return 1 - fi + return 1 } remove_repofile_if_unused() { #Given a sources.list.d file, delete it if nothing from that repository is currently installed. Deletion skipped if $2 is 'test'