Skip to content

Instantly share code, notes, and snippets.

@kapadia
Created November 6, 2014 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kapadia/403ed7676742ecb7e760 to your computer and use it in GitHub Desktop.
Save kapadia/403ed7676742ecb7e760 to your computer and use it in GitHub Desktop.
Parallel Experiment
#!/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