1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| #!/bin/bash
function buildProject
{
argList="$(echo $* | tr ' ' '\n')"
newArgList="$argList"
buildingDone="false"
while [ $buildingDone = "false" ]
do
if [ -n "$argList" ]
then
for arg in $argList
do
if [ $(echo $arg | awk -F ',' '{print NF}') = "1" ]
then
bash -c "echo 'building '$arg'...'; sleep 5" &
newArgList="$(echo "$newArgList" | sed -e 's/,*'$arg'//')"
fi
done
wait
argList="$newArgList"
else
buildingDone="true"
fi
done
}
buildProject arg0 arg1 arg2,arg1 arg3,arg0,arg2 |
Partager