diff options
author | Martin Peres <martin.peres@linux.intel.com> | 2016-01-30 17:06:40 +0200 |
---|---|---|
committer | Martin Peres <martin.peres@linux.intel.com> | 2016-01-30 17:08:10 +0200 |
commit | 2a6d4c26ae4c68885d7fcc1d259113aae78d79fa (patch) | |
tree | 3e3bb01b997d2a5db141e71910132ce445fca4b0 | |
parent | 8a7374c7e7556747de0b6a64d5f448b954c59cf9 (diff) |
core: make sure we set-up the exit function before parsing any user script
-rwxr-xr-x | core.sh | 56 |
1 files changed, 28 insertions, 28 deletions
@@ -259,6 +259,34 @@ function read_git_version_deployed() { return 1 } +# functions to call on exit +function __ezbench_reset_git_state__ { + git reset --hard "$commit_head" 2> /dev/null + [ -n "$stash" ] && git stash apply "$stash" > /dev/null +} + +function __ezbench_finish__ { + exitcode=$? + action=$1 + + # to be executed on exit, possibly twice! + __ezbench_reset_git_state__ + + # Execute the user-defined post hook + callIfDefined ezbench_post_hook + + if [ "$action" == "reboot" ] + then + printf "Rebooting with error code $exitcode\n" + sudo reboot + else + printf "Exiting with error code $exitcode\n" + exit $exitcode + fi +} +trap __ezbench_finish__ EXIT +trap __ezbench_finish__ INT # Needed for zsh + # Execute the user-defined pre hook callIfDefined ezbench_pre_hook @@ -301,34 +329,6 @@ for id in "$@"; do commitList+=" " done -# functions to call on exit -function __ezbench_reset_git_state__ { - git reset --hard "$commit_head" 2> /dev/null - [ -n "$stash" ] && git stash apply "$stash" > /dev/null -} - -function __ezbench_finish__ { - exitcode=$? - action=$1 - - # to be executed on exit, possibly twice! - __ezbench_reset_git_state__ - - # Execute the user-defined post hook - callIfDefined ezbench_post_hook - - if [ "$action" == "reboot" ] - then - printf "Rebooting with error code $exitcode\n" - sudo reboot - else - printf "Exiting with error code $exitcode\n" - exit $exitcode - fi -} -trap __ezbench_finish__ EXIT -trap __ezbench_finish__ INT # Needed for zsh - # Seed the results with the last round? commitListLog="$logsFolder/commit_list" last_commit=$(tail -1 "$commitListLog" 2>/dev/null | cut -f 1 -d ' ') |