Skip to content

Commit b3006b5

Browse files
authored
Update forkrun.bash
1 parent b3913d8 commit b3006b5

File tree

1 file changed

+29
-34
lines changed

1 file changed

+29
-34
lines changed

forkrun.bash

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,57 +1159,52 @@ p_PID+=(\${p{<#>}_PID})""" )"
11591159
# initialize real-time printing of ordered output as forkrun runs
11601160
outCur=10
11611161
continueFlag=true
1162+
outPrint=()
11621163

11631164
while ${continueFlag}; do
11641165

11651166
# read order indices that are done running.
1166-
while true; do
1167-
read -r -u ${fd_nOrder0}
1168-
case "${REPLY}" in
1169-
+([0-9]))
1170-
# index has an output file
1171-
outHave[${REPLY}]=1
1172-
;;
1173-
x+([0-9]))
1174-
# index was empty
1175-
outHave[${REPLY#x}]=0
1176-
;;
1177-
'')
1178-
# end condition was met
1179-
continueFlag=false
1180-
break
1181-
;;
1182-
esac
1183-
[[ ${outHave[${outCur}]} ]] && break
1184-
done
1167+
read -r -u ${fd_nOrder0}
1168+
case "${REPLY}" in
1169+
+([0-9]))
1170+
# index has an output file
1171+
outHave[${REPLY}]=1
1172+
;;
1173+
x+([0-9]))
1174+
# index was empty
1175+
outHave[${REPLY#x}]=0
1176+
;;
1177+
'')
1178+
# end condition was met
1179+
continueFlag=false
1180+
break
1181+
;;
1182+
esac
11851183

11861184
# starting at $outCur, print all indices in sequential order that have been recorded as being run and then remove the tmp output file[s]
11871185

1188-
outPrint=()
1189-
1190-
while (( ${#outPrint[@]} < 128 )); do
1191-
case "${outHave[${outCur}]}" in
1192-
1)
1193-
outPrint+=("${tmpDir}/.out/x${outCur}")
1194-
;;
1195-
0)
1196-
1197-
;;
1198-
*)
1199-
break
1200-
;;
1201-
esac
1186+
while [[ "${outHave[${outCur}]}" ]]; do
1187+
1188+
[[ "${outHave[${outCur}]}" == 1 ]] && outPrint+=("${tmpDir}/.out/x${outCur}")
12021189

12031190
unset "outHave[${outCur}]"
12041191

12051192
# advance outCur by 1
12061193
((outCur++))
12071194
[[ "${outCur}" == +(9)+(0) ]] && outCur="${outCur}00"
1195+
1196+
[[ ${#outPrint[@]} == 128 ]] && {
1197+
cat "${outPrint[@]}"
1198+
\rm -f "${outPrint[@]}"
1199+
outPrint=()
1200+
}
1201+
12081202
done
1209-
1203+
12101204
[[ ${#outPrint[@]} == 0 ]] || {
12111205
cat "${outPrint[@]}"
12121206
\rm -f "${outPrint[@]}"
1207+
outPrint=()
12131208
}
12141209

12151210
# check for end condition

0 commit comments

Comments
 (0)