[PATCH 6 of 7] scripts/functions: use array variables for URLs list

Yann E. MORIN yann.morin.1998@anciens.enib.fr
Tue Aug 2 23:01:00 GMT 2011


 scripts/functions |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)


# HG changeset patch
# User "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
# Date 1312322444 -7200
# Node ID 930fdc89752b836b02fed445940bb6f9df09f778
# Parent  3738af3d8a081863eebf49299c329dd58acbcca7
scripts/functions: use array variables for URLs list

This is needed later, when we'll conditionnally use both the
upstream and the mirror URLs.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>

diff --git a/scripts/functions b/scripts/functions
--- a/scripts/functions
+++ b/scripts/functions
@@ -513,7 +513,8 @@
 # Usage: CT_GetFile <basename> [.extension] <url> [url ...]
 CT_GetFile() {
     local ext
-    local url URLS
+    local -A URLS
+    local url
     local file="$1"
     local first_ext
     shift
@@ -535,17 +536,18 @@
     # Add URLs on the LAN mirror
     if [ "${CT_USE_MIRROR}" = "y" ]; then
         CT_TestOrAbort "Please set the mirror base URL" -n "${CT_MIRROR_BASE_URL}"
-        URLS="${CT_MIRROR_BASE_URL}/${file%-*} ${CT_MIRROR_BASE_URL}"
+        URLS+=( "${CT_MIRROR_BASE_URL}/${file%-*}" )
+        URLS+=( "${CT_MIRROR_BASE_URL}" )
     fi
 
-    URLS+="${URLS:+ }${*}"
+    URLS+=( "${@}" )
 
     # Scan all URLs in turn, and try to grab a tarball from there
     # Do *not* try git trees (ext=/.git), this is handled in a specific
     # wrapper, below
     for ext in ${first_ext} .tar.bz2 .tar.gz .tgz .tar ''; do
         # Try all urls in turn
-        for url in ${URLS}; do
+        for url in "${URLS[@]}"; do
             [ -n "${url}" ] || continue
             CT_DoLog DEBUG "Trying '${url}/${file}${ext}'"
             CT_DoGetFile "${url}/${file}${ext}"

--
For unsubscribe information see http://sourceware.org/lists.html#faq



More information about the crossgcc mailing list