From 6ff0130a5314bf3592f0364cd86e87ca95506a07 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 12 Dec 2011 13:31:26 +0100 Subject: [PATCH] Since /bin/sh has no arrays do not use them in update-cvarcount.sh --- update-cvarcount.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/update-cvarcount.sh b/update-cvarcount.sh index d59d9ac45..78985b819 100755 --- a/update-cvarcount.sh +++ b/update-cvarcount.sh @@ -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..." -- 2.39.2