From 4835afbe4aaac15f0682fc3e0d803331c2cfc27b Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 15 Dec 2014 15:29:37 -0800 Subject: [PATCH] simplify and print in order --- xwords4/linux/scripts/discon_ok2.sh | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/xwords4/linux/scripts/discon_ok2.sh b/xwords4/linux/scripts/discon_ok2.sh index d0897dada..352bca134 100755 --- a/xwords4/linux/scripts/discon_ok2.sh +++ b/xwords4/linux/scripts/discon_ok2.sh @@ -226,6 +226,7 @@ build_cmds() { # PARAMS="$PARAMS --savefail-pct 10" [ -n "$SEED" ] && PARAMS="$PARAMS --seed $RANDOM" PARAMS="$PARAMS $PUBLIC" + ARGS[$COUNTER]=$PARAMS ROOMS[$COUNTER]=$ROOM FILES[$COUNTER]=$FILE @@ -457,12 +458,10 @@ update_ldevid() { fi } -summarizeLogs() { - local COUNT=${#ARGS[*]} +summarizeTileCounts() { local STR='' - local INDX=0 - while [ $INDX -lt $COUNT ]; do - local KEY=${KEYS[$INDX]} + local KEYS=( ${!ARGS[*]} ) + for KEY in ${KEYS[@]}; do local LOG=${LOGS[$KEY]} local LINE=$(grep pool_removeTiles $LOG | tail -n 1) @@ -470,13 +469,10 @@ summarizeLogs() { local NUM=$(echo $LINE | sed 's,^.*removeTiles: \(.*\) tiles.*$,\1,') STR="${STR}${KEY}:${NUM};" fi - - INDX=$((1 + INDX)) done if [ -n "${STR}" ]; then - echo -n "$(date +%r) tiles left: " - echo $STR; + echo "$(date +%r) tiles left: $STR" fi } @@ -496,11 +492,11 @@ run_cmds() { LOOPCOUNT=$((1 + LOOPCOUNT)) if [ 0 -eq $((LOOPCOUNT % 20)) ]; then - summarizeLogs + summarizeTileCounts fi INDX=$(($RANDOM%COUNT)) - KEYS=( ${!ARGS[*]} ) + local KEYS=( ${!ARGS[*]} ) KEY=${KEYS[$INDX]} ROOM=${ROOMS[$KEY]} if [ 0 -eq ${PIDS[$KEY]} ]; then