]> git.xonotic.org Git - xonotic/xonotic.git/commitdiff
Use time only if it exists.
authorRudolf Polzer <divverent@xonotic.org>
Wed, 15 Jan 2014 16:01:38 +0000 (17:01 +0100)
committerRudolf Polzer <divverent@xonotic.org>
Wed, 15 Jan 2014 16:01:38 +0000 (17:01 +0100)
misc/tools/all/config.subr
misc/tools/all/git.subr
misc/tools/all/xonotic.subr

index ab4445e7087656d0fc945da1a8d2cb884e99e2e3..2ebddfb3cf390c670d8c187736a00190ac548aa5 100644 (file)
@@ -34,3 +34,9 @@ allmirrors()
 
        "$@" ssh  push ssh://xonotic@push.git.xonotic.org/ ''
 }
+
+if ! { time -p sh -c 'true'; } >/dev/null 2>&1; then
+       time=
+else
+       time="time -p"
+fi
index a7f7d354dba78b047733f72b38653911fc14cbe6..c29685dc6622334f04f6ab708d75abfd05a0b5d9 100644 (file)
@@ -56,7 +56,7 @@ 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
        # if we can't time, we only check availability
-       if ! { time -p sh -c 'true'; } >/dev/null 2>&1; then
+       if [ -z "$time" ]; then
                echo 0
                return
        fi
@@ -64,7 +64,7 @@ mirrorspeed()
        (
                set +x
                export REPO=$1 # so that the sh -c subshell can use it
-               { time -p sh -c 'git ls-remote "$REPO" refs/heads/master >/dev/null 2>&1'; } 2>&1 >/dev/null | head -n 1 | cut -d ' ' -f 2 | tr -d . | sed 's,^0*,,' | grep . || echo 0
+               { $time sh -c 'git ls-remote "$REPO" refs/heads/master >/dev/null 2>&1'; } 2>&1 >/dev/null | head -n 1 | cut -d ' ' -f 2 | tr -d . | sed 's,^0*,,' | grep . || echo 0
                        # unit: clock ticks (depends on what "time" returns
        )
 }
index 8cfbd9c477f25c98b01a753710d4b7bcf0185b6e..7be8fa065c3c6f50994a3dba96ce4b755e1829e6 100644 (file)
@@ -17,7 +17,7 @@ case "$cmd" in
                        if [ ! -f "$mapfile" ] ; then
                                msg "ERROR, $mapfile not found!"
                        else
-                               time misc/tools/xonotic-map-compiler-optionsfile "$mapfile"
+                               $time misc/tools/xonotic-map-compiler-optionsfile "$mapfile"
                        fi
                done
                ;;
@@ -336,7 +336,7 @@ case "$cmd" in
                        set -- rlwrap -A -g '^quit' -q "\"" -s 10000 -S ']' -w 100 "$@"
                fi
                rm -f xonotic.core
-               time "$@" || true
+               $time "$@" || true
                if [ -f xonotic.core ]; then
                        if yesno "The program has CRASHED. Do you want to examine the core dump?"; then
                                gdb "$binary" xonotic.core