Skip to content

Instantly share code, notes, and snippets.

@carinadigital
Created January 30, 2019 13:28
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 carinadigital/16c995f62c8eee2cbbee6b0792f9b2df to your computer and use it in GitHub Desktop.
Save carinadigital/16c995f62c8eee2cbbee6b0792f9b2df to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euxo pipefail
# 0 - Processed record. No more to process
# 20 - Processed record. More to process
# Other - Unspecified error
# Process one record
migrate_one_record() {
set +e # Don't fail on errors immediately in this function.
(exit $1) # Simulate a failure based on the function parameter
local function_exit_code=$?
return $function_exit_code
}
echo "Start"
for i in 1 2 3 5 20 0 # This is just to simlate exit codes from a program
do
migrate_one_record $i
loop_exit_code=$?
case "$loop_exit_code" in
0) echo "Normal exit. Nothing more to process. $loop_exit_code"
;;
20) echo "Normal exit. More to process. $loop_exit_code"
;;
*) echo "Error $loop_exit_code "
;;
esac
done
echo "Finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment