Created
January 30, 2019 13:28
-
-
Save carinadigital/16c995f62c8eee2cbbee6b0792f9b2df to your computer and use it in GitHub Desktop.
This file contains hidden or 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 -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