Created
November 6, 2014 22:19
-
-
Save kapadia/403ed7676742ecb7e760 to your computer and use it in GitHub Desktop.
Parallel Experiment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eou pipefail | |
function onerror() { | |
echo "onerror" $? | |
exit 1 | |
} | |
trap onerror EXIT | |
function error() { | |
exit 1; | |
} | |
export -f error | |
function work() { | |
num=$1; | |
[[ $num -eq 2 ]] && error || echo "$num NO" | |
echo "HI THERE $num" | |
} | |
export -f work | |
parallel work {} ::: `seq 1 10` | |
echo "HERE $?" | |
trap - EXIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment