]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Since /bin/sh has no arrays do not use them in update-cvarcount.sh
authorterencehill <piuntn@gmail.com>
Mon, 12 Dec 2011 12:31:26 +0000 (13:31 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 12 Dec 2011 12:31:26 +0000 (13:31 +0100)
update-cvarcount.sh

index d59d9ac45087fc8e0d6e51273789643da5c33cce..78985b81947af96ede8d5800c0bb1d42f38e35aa 100755 (executable)
@@ -1,34 +1,30 @@
 #!/bin/sh
 
-maincfg[0]=balanceXonotic.cfg
-   cfgs[0]=balance*.cfg
- prefix[0]="/^seta? g_/"
-
-maincfg[1]=_hud_descriptions.cfg
-   cfgs[1]=hud_*.cfg
- prefix[1]="/^seta? hud_/"
-
 errord=false
 
-for index in 0 1; do
-       countw=`awk ''"${prefix[index]}"' { print $2; }' "${maincfg[index]}" | sort -u | tr -d '\r' | git hash-object --stdin | cut -c 1-32`
-       for b in ${cfgs[index]}; do
-               countb=`awk ''"${prefix[index]}"' { print $2; }' "$b" | sort -u | tr -d '\r' | git hash-object --stdin | cut -c 1-32`
+check_files()
+{
+       countw=`awk ''"$3"' { print $2; }' "$1" | sort -u | tr -d '\r' | git hash-object --stdin | cut -c 1-32`
+       for b in $2; do
+               countb=`awk ''"$3"' { print $2; }' "$b" | sort -u | tr -d '\r' | git hash-object --stdin | cut -c 1-32`
                if [ "$countw" != "$countb" ]; then
-                       echo "Mismatch between "${maincfg[index]}" and $b. Aborting."
+                       echo "Mismatch between "$1" and $b. Aborting."
                        echo "Differences are:"
                        echo "< missing in $b"
                        echo "> must get removed from $b"
                        A=`mktemp || echo a.tmp`
                        B=`mktemp || echo b.tmp`
-                       awk ''"${prefix[index]}"' { print $2; }' "${maincfg[index]}"      | sort -u | tr -d '\r' > "$A"
-                       awk ''"${prefix[index]}"' { print $2; }' "$b"                     | sort -u | tr -d '\r' > "$B"
+                       awk ''"$3"' { print $2; }' "$1"      | sort -u | tr -d '\r' > "$A"
+                       awk ''"$3"' { print $2; }' "$b"                     | sort -u | tr -d '\r' > "$B"
                        diff "$A" "$B" | grep '^[<>]' | sort
                        rm -f "$A" "$B"
                        errord=true
                fi
        done
-done
+}
+
+check_files "balanceXonotic.cfg" "balance*.cfg" "/^seta? g_/"
+check_files "_hud_descriptions.cfg" "hud_*.cfg" "/^seta? hud_/"
 
 if $errord; then
        echo "Please wait for 30 seconds, so you have had enough time to read this..."