Mercurial > hg > aboriginal
diff sources/functions.sh @ 720:74850275fe41
Make "wait4background" with no arguments wait for all background tasks.
author | Rob Landley <rob@landley.net> |
---|---|
date | Sun, 26 Apr 2009 14:19:21 -0500 |
parents | 90ab1a1f4db5 |
children | 3ccce25660f4 |
line wrap: on
line diff
--- a/sources/functions.sh Fri Apr 24 22:33:31 2009 -0500 +++ b/sources/functions.sh Sun Apr 26 14:19:21 2009 -0500 @@ -343,14 +343,17 @@ echo -en "\033]2;$ARCH_NAME $STAGE_NAME $PACKAGE\007" } -# usage: wait4background 0 +# usage: wait4background [count] function wait4background() { + local COUNT="$1" local EXCLUDE="$2" + + [ -z "$COUNT" ] && COUNT=0 [ -z "$EXCLUDE" ] && EXCLUDE="thisdoesnotmatchanything" # Wait for background tasks to finish - while [ $(jobs | grep -v "$EXCLUDE" | wc -l) -gt $1 ] + while [ $(jobs | grep -v "$EXCLUDE" | wc -l) -gt $COUNT ] do sleep 1 # Without this next line, bash never notices a change in the number of jobs.