In statement tasks="(sleep $i; true && echo ok) & ${tasks}"
:
- The boolean
true
represents command execution that finish byexit 0
- You can test with
true; echo $?
{ (sleep 3; true && echo ok) & (sleep 2; true && echo ok) & } | grep -c ok | ( read n && (( n==2 )) ) ; echo $?
- A boolean
false
in this example represents command execution that finish byexit 1
(other exit code) - You can test with
false; echo $?
{ (sleep 3; true && echo ok) & (sleep 2; false && echo ok) & } | grep -c ok | ( read n && (( n==2 )) ) ; echo $?
i=0
tasks=''
for engine in 1 2 3
do
i=$(($i+1))
tasks="(sleep $i; true && echo ok) & ${tasks}"
done
echo "Executed command: eval '{ ${tasks} } | grep -c ok | ( read n && (( n==${i} )) ) ; echo \$?'"
# synchronisation barrier with exitstatus ckeck
exitstatus=$(eval "{ ${tasks} } | grep -c ok | ( read n && (( n==${i} )) ) ; echo \$?")
echo $exitstatus
- Launch several ruby tests and verify that all pass:
#!/bin/bash
i=0
tasks=''
cd engines
for engine in 1 2 3
do
i=$(($i+1))
tasks="(cd `bundle show $engine`; bundle exec rspec && echo ok) & ${tasks}"
done
echo "Executed command: eval '{ ${tasks} } | grep -c ok | ( read n && (( n==${i} )) ) ; echo \$?'"
# synchronisation barrier with exitstatus ckeck
exitstatus=$(eval "{ ${tasks} } | grep -c ok | ( read n && (( n==${i} )) ) ; echo \$?")
echo $exitstatus