fetchurl: fix handling of fallback URLs

Without the change fallback to `urls = []` does not
work as `$urls` evaluates on ony first entry. Use
`${urls[@]}` instead.

Example derivation that is fixed in `master` is
`xterm.src`:

Before:

    $ nix build --no-link -f. xterm.src --rebuild -L
    xterm> structuredAttrs is enabled
    ...
    xterm> trying ftp://ftp.invisible-island.net/xterm/xterm-403.tgz
    ...
    xterm> curl: (67) Access denied: 550
    xterm> error: cannot download xterm-403.tgz from any mirror

After:

    $ nix build --no-link -f. xterm.src --rebuild -L
    xterm> structuredAttrs is enabled
    ...
    xterm> trying ftp://ftp.invisible-island.net/xterm/xterm-403.tgz
    ...
    xterm> curl: (67) Access denied: 550
    ...
    xterm> trying https://invisible-mirror.net/archives/xterm/xterm-403.tgz
    xterm>   % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
    xterm>                                  Dload  Upload   Total   Spent    Left  Speed
    xterm> 100  1577k 100  1577k   0     0 703670     0   0:00:02  0:00:02 --:--:-- 703866
This commit is contained in:
Sergei Trofimovich
2025-12-14 07:22:20 +00:00
parent 0b7f978200
commit 23236b331d
+1 -1
View File
@@ -109,7 +109,7 @@ tryHashedMirrors() {
set -o noglob
urls2=
for url in $urls; do
for url in "${urls[@]}"; do
if test "${url:0:9}" != "mirror://"; then
urls2="$urls2 $url"
else