diff options
-rw-r--r-- | CHANGES.md | 1 | ||||
-rw-r--r-- | src/rankmirrors.sh.in | 16 |
2 files changed, 10 insertions, 7 deletions
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed - Create pipelines for and satisfy markdownlint-cli2, ShellCheck, and Vint (!32, !33, !34, 41554d65, d674bf23) (Matthew Armand, Robin Candau, Daniel M. Capella) +- rankmirrors: Fix word-splitting (!36) (Victor Westerhuis) ## [1.9.1] - 2023-07-13 diff --git a/src/rankmirrors.sh.in b/src/rankmirrors.sh.in index 84c1a36..29197ad 100644 --- a/src/rankmirrors.sh.in +++ b/src/rankmirrors.sh.in @@ -69,7 +69,7 @@ err() { # gettime fetchurl (e.g gettime http://foo.com/core/os/i686/core.db.tar.gz) # returns the fetching time, or timeout, or unreachable gettime() { - IFS=' ' output=( "$(curl -s -m "$MAX_TIME" -w "%{time_total} %{http_code}" "$1" -o/dev/null)" ) + IFS=' ' read -ra output <<< "$(curl -s -m "$MAX_TIME" -w "%{time_total} %{http_code}" "$1" -o/dev/null)" (( $? == 28 )) && echo timeout && return (( output[1] >= 400 || ! output[1] )) && echo unreachable && return echo "${output[0]}" @@ -166,7 +166,9 @@ while [[ $1 ]]; do if [[ ! ${1:1:1} ]]; then [[ -t 0 ]] && err "Stdin is empty." - IFS=$'\n' linearray=( "$(</dev/stdin)" ) + while read -r value; do + linearray+=( "$value" ) + done STDIN=1 shift else @@ -202,11 +204,11 @@ while [[ $1 ]]; do fi elif [[ -f $1 ]]; then FILE="1" - IFS=$'\n' linearray=( "$(<"$1")" ) - for value in "${linearray[@]}"; do - [[ "$value" ]] || err "File is empty." - shift - done + while read -r value; do + linearray+=( "$value" ) + done < "$1" + [[ ${linearray[*]} ]] || err "File is empty." + shift else err "'$1' does not exist." fi |