]> git.notmuchmail.org Git - notmuch/commitdiff
test/thread-order: more robust loop exit in case of broken input
authorTomi Ollila <tomi.ollila@iki.fi>
Sun, 29 Mar 2015 15:30:36 +0000 (18:30 +0300)
committerDavid Bremner <david@tethera.net>
Fri, 3 Apr 2015 00:27:57 +0000 (09:27 +0900)
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.

test/T260-thread-order.sh

index 99f58336f2253a8906d03cbb61028d1c954b49fb..5239bd443512988f9d11f04fa4cba1894db918c1 100755 (executable)
@@ -45,9 +45,12 @@ for ((n = 0; n < 4; n++)); do
     while read -a parents; do
         references=""
         parent=${parents[$n]}
     while read -a parents; do
         references=""
         parent=${parents[$n]}
-        while [[ $parent != None ]]; do
+        while [[ ${parent:-None} != None ]]; do
             references="<m$parent@t$thread> $references"
             references="<m$parent@t$thread> $references"
+            pp=$parent
             parent=${parents[$parent]}
             parent=${parents[$parent]}
+            # Avoid looping over broken input (if ever)
+            parents[$pp]="None"
         done
 
         generate_message \
         done
 
         generate_message \