From: Tomi Ollila Date: Sun, 29 Mar 2015 15:30:36 +0000 (+0300) Subject: test/thread-order: more robust loop exit in case of broken input X-Git-Tag: 0.20~16 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=3d1483df12050dec8a2df95249576162a0e79302 test/thread-order: more robust loop exit in case of broken input When creating $THREADS data it may end of not having 'None' at all or the numbers in line output yields a loop. To avoid loop the value in current array index is set to 'None' so that if the same item is reached again the loop will end. Also empty string as next array index will end the loop. --- diff --git a/test/T260-thread-order.sh b/test/T260-thread-order.sh index 99f58336..5239bd44 100755 --- a/test/T260-thread-order.sh +++ b/test/T260-thread-order.sh @@ -45,9 +45,12 @@ for ((n = 0; n < 4; n++)); do while read -a parents; do references="" parent=${parents[$n]} - while [[ $parent != None ]]; do + while [[ ${parent:-None} != None ]]; do references=" $references" + pp=$parent parent=${parents[$parent]} + # Avoid looping over broken input (if ever) + parents[$pp]="None" done generate_message \