view lemuriformes/waiter.sh @ 18:56596902e9ae default tip

add some setup + tests
author Jeff Hammel <k0scist@gmail.com>
date Sun, 10 Dec 2017 17:57:03 -0800
parents 4793f99b73e0
children
line wrap: on
line source

#!/bin/bash

# parallelize and wait for a set of jobs;
# it's MapReduce for `bash`!

FAIL=0

# See http://jeremy.zawodny.com/blog/archives/010717.html

{{for command in commands}}
{{command}} &
{{endfor}}

# wait for processes
for job in `jobs -p`
do
    echo ${job}
    wait ${job} || let "FAIL+=1"
done

if [ "${FAIL}" == "0" ]
then
    exit 0
fi

echo "${FAIL} failing job(s)"
exit 1