From b71dd5e57ebe19ce206f9ea896ede5baa3805c9e Mon Sep 17 00:00:00 2001 From: Ben Yu <124392880+xby-G@users.noreply.github.com> Date: Tue, 14 May 2024 09:43:18 -0400 Subject: [PATCH] Fix the script to fix two scenarios: 1. No source list file needs to be updated 2. Multiple source list files need to be updated (#1180) --- python/pip-install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/pip-install.sh b/python/pip-install.sh index 677cb2107..866d65c3a 100755 --- a/python/pip-install.sh +++ b/python/pip-install.sh @@ -20,9 +20,9 @@ function remove_old_backports { oldstable=$(curl -s https://deb.debian.org/debian/dists/oldstable/Release | awk '/^Codename/ {print $2}'); stable=$(curl -s https://deb.debian.org/debian/dists/stable/Release | awk '/^Codename/ {print $2}'); - matched_files="$(grep -rsil '\-backports' /etc/apt/sources.list*)" + matched_files=( $(grep -rsil '\-backports' /etc/apt/sources.list*||:) ) if [[ -n "$matched_files" ]]; then - for filename in "$matched_files"; do + for filename in "${matched_files[@]}"; do grep -e "$oldstable-backports" -e "$stable-backports" "$filename" || \ sed -i -e 's/^.*-backports.*$//' "$filename" done