diff options
author | David Williams | 2016-04-25 20:18:55 +0000 |
---|---|---|
committer | David Williams | 2016-04-25 20:18:55 +0000 |
commit | dfeaa967879a2132ab98dfc05bd8d8c0d6867d3b (patch) | |
tree | 24da7dd048c46749dd7fd4360977d5b4982491a6 /production/miscToolsAndNotes/misc/checkForErrorExit.sh | |
parent | 8c73859f8e2f17374df41fbad78b69709f6fabcc (diff) | |
download | eclipse.platform.releng.aggregator-dfeaa967879a2132ab98dfc05bd8d8c0d6867d3b.tar.gz eclipse.platform.releng.aggregator-dfeaa967879a2132ab98dfc05bd8d8c0d6867d3b.tar.xz eclipse.platform.releng.aggregator-dfeaa967879a2132ab98dfc05bd8d8c0d6867d3b.zip |
[releng] Misc cleanup and clarification
Diffstat (limited to 'production/miscToolsAndNotes/misc/checkForErrorExit.sh')
-rwxr-xr-x | production/miscToolsAndNotes/misc/checkForErrorExit.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/production/miscToolsAndNotes/misc/checkForErrorExit.sh b/production/miscToolsAndNotes/misc/checkForErrorExit.sh new file mode 100755 index 000000000..06cbdfa65 --- /dev/null +++ b/production/miscToolsAndNotes/misc/checkForErrorExit.sh @@ -0,0 +1,29 @@ + +# TODO: an enhanced version was put directly in 'wgetFreshSDKdir.sh' +# Should check if this is used anywhere, and delete, if not. + +function checkForErrorExit () +{ + # arg 1 must be return code, $? + # arg 2 (remaining line) can be message to print before exiting due to non-zero exit code + exitCode=$1 + shift + message="$*" + if [ -z "${exitCode}" ] + then + echo "PROGRAM ERROR: checkForErrorExit called with no arguments" + exit 1 + fi + if [ -z "${message}" ] + then + echo "WARNING: checkForErrorExit called without message" + message="(Calling program provided no message)" + fi + if [ "${exitCode}" -ne "0" ] + then + echo + echo " ERROR. exit code: ${exitCode} ${message}" + echo + exit "${exitCode}" + fi +} |