fetchurl: builder.sh: handle urls as a Bash array
Clean up leftover for commitcd13136f03("fetchurl: use __structuredAttrs = true and pass curlOptsList directly") Continue the work of commit23236b331d("fetchurl: fix handling of fallback URLs"), addressing a Bash array re-assignment quirk: when assigning a Bash array variable as if it were a plain variable, the value goes to the first element, and the rest of the array stays the same. ```console $ foo=(a b) $ declare -p foo declare -a foo=([0]="a" [1]="b") $ foo="c d" $ declare -p foo declare -a foo=([0]="c d" [1]="b") ``` Don't rewrite the `${urls[@]}` with resolved URLs, but hold them with `${resolvedUrls[@]}` instead. Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk> Co-authored-by: Wolfgang Walther <walther@technowledgy.de>
This commit is contained in:
co-authored by
Matt Sturgeon
Wolfgang Walther
parent
1e5ca4eadb
commit
fc180191de
@@ -124,10 +124,10 @@ tryHashedMirrors() {
|
||||
# URL list may contain ?. No glob expansion for that, please
|
||||
set -o noglob
|
||||
|
||||
urls2=
|
||||
resolvedUrls=()
|
||||
for url in "${urls[@]}"; do
|
||||
if test "${url:0:9}" != "mirror://"; then
|
||||
urls2="$urls2 $url"
|
||||
resolvedUrls+=("$url")
|
||||
else
|
||||
url2="${url:9}"; echo "${url2/\// }" > split; read site fileName < split
|
||||
#varName="mirror_$site"
|
||||
@@ -142,18 +142,17 @@ for url in "${urls[@]}"; do
|
||||
if test -n "${!varName}"; then mirrors="${!varName}"; fi
|
||||
|
||||
for url3 in $mirrors; do
|
||||
urls2="$urls2 $url3$fileName";
|
||||
resolvedUrls+=("$url3$fileName");
|
||||
done
|
||||
fi
|
||||
fi
|
||||
done
|
||||
urls="$urls2"
|
||||
|
||||
# Restore globbing settings
|
||||
set +o noglob
|
||||
|
||||
if test -n "$showURLs"; then
|
||||
echo "$urls" > $out
|
||||
echo "${resolvedUrls[*]}" > $out
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -165,7 +164,7 @@ fi
|
||||
set -o noglob
|
||||
|
||||
success=
|
||||
for url in $urls; do
|
||||
for url in "${resolvedUrls[@]}"; do
|
||||
if [ -z "$postFetch" ]; then
|
||||
case "$url" in
|
||||
https://github.com/*/archive/*)
|
||||
|
||||
Reference in New Issue
Block a user