From 07634a0d1302aaebbe1c457786e537992c124240 Mon Sep 17 00:00:00 2001 From: sebthom Date: Tue, 8 Aug 2023 22:10:31 +0200 Subject: [PATCH] replacing "echo .. | head -1" to avoid broken pipes #1 --- fast-apt-mirror.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fast-apt-mirror.sh b/fast-apt-mirror.sh index a5f7d40..e22b4bd 100644 --- a/fast-apt-mirror.sh +++ b/fast-apt-mirror.sh @@ -340,12 +340,12 @@ function find_fast_mirror() { >&2 echo "ERROR: Could not determine any fast mirror matching required criterias." return $RC_MISC_ERROR fi - fastest_mirror=$(echo "$mirrors_with_speed" | head -1 | cut -d" " -f2) - fastest_mirror_speed=$(echo "$mirrors_with_speed" | head -1 | cut -d" " -f1 | numfmt --to=iec --suffix=B/s) + fastest_mirror=$(echo "${mirrors_with_speed%%$'\n'*}" | cut -d" " -f2) + fastest_mirror_speed=$(echo "${mirrors_with_speed%%$'\n'*}" | cut -d" " -f1 | numfmt --to=iec --suffix=B/s) >&2 echo " -> $fastest_mirror ($fastest_mirror_speed) determined as fastest mirror within $(( $(date +%s) - start_at )) seconds" if [[ ${verbosity:-} -gt 0 ]]; then echo "$mirrors_with_speed" | tail -n +2 | while IFS= read -r mirror; do - mirror_speed=$(echo "$mirror" | head -1 | cut -d" " -f1 | numfmt --to=iec --suffix=B/s) + mirror_speed=$(echo "${mirror%%$'\n'*}" | cut -d" " -f1 | numfmt --to=iec --suffix=B/s) >&2 echo " -> $(echo "$mirror" | cut -d" " -f2) ($mirror_speed)" done fi