]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - all
mirror selection: bail out if "time" does not exist
[xonotic/xonotic.git] / all
diff --git a/all b/all
index e750d9ae491067e7956b23ae63c06a613a5b58cd..2ddb919f886e5543d8d9d2bbbd8f7b329133e5dd 100755 (executable)
--- a/all
+++ b/all
@@ -339,16 +339,11 @@ mkzip0()
        zip -0y "$@"
 }
 
-timewrapper()
-{
-       time -p "$@"
-}
-
 mirrorspeed()
 {
        # first result is to be ignored, but we use it to check status
        git ls-remote "$1" refs/heads/master >/dev/null 2>&1 || return 1
-       timewrapper git ls-remote "$1" refs/heads/master 2>&1 >/dev/null | head -n 1 | cut -d ' ' -f 2 | tr -d . | sed 's,^0*,,'
+       { time -p git ls-remote "$1" refs/heads/master; } 2>&1 >/dev/null | head -n 1 | cut -d ' ' -f 2 | tr -d . | sed 's,^0*,,'
                # unit: clock ticks (depends on what "time" returns
 }
 
@@ -357,6 +352,10 @@ bestmirror()
        pre=$1; shift
        suf=$1; shift
 
+       if ! { time -p true; } >/dev/null 2>&1; then
+               return 1
+       fi
+
        bestin=
        bestt=
        for in in "$@"; do
@@ -373,8 +372,12 @@ bestmirror()
                        msg "$m -> FAIL"
                fi
        done
-       msg "Best mirror seems to be $pre$bestin$suf"
-       echo "$bestin"
+       if [ -n "$bestin" ]; then
+               msg "Best mirror seems to be $pre$bestin$suf"
+               echo "$bestin"
+       else
+               return 1
+       fi
 }
 
 case "$cmd" in
@@ -515,7 +518,11 @@ case "$cmd" in
                                base=`echo "$base" | sed "s,://\(.*\.\)\?git.xonotic.org/,:// .git.xonotic.org/,"`
                                case "$base" in
                                        *\ *)
-                                               location=`bestmirror $base"xonotic.git" de nl`
+                                               if location=`bestmirror $base"xonotic.git" de nl`; then
+                                                       :
+                                               else
+                                                       location=
+                                               fi
                                                ;;
                                        *)
                                                location=