Skip to content

Commit

Permalink
replacing "echo .. | head -1" to avoid broken pipes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
sebthom committed Aug 8, 2023
1 parent 8da8be3 commit 07634a0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fast-apt-mirror.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 07634a0

Please sign in to comment.