From 993cb4519f7a2a82711669434667432340d0261b Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 23 Aug 2025 22:51:08 +0200 Subject: [PATCH] Add runner script --- runner/runner.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 runner/runner.sh diff --git a/runner/runner.sh b/runner/runner.sh new file mode 100755 index 0000000..440e102 --- /dev/null +++ b/runner/runner.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +set -e + +SCRIPT=$(realpath -- "$1") +cd -- "$(dirname -- "$SCRIPT")" + +_CISH_STARTED=false + +function _cish_on_command() { + _CISH_EXIT_CODE=$? + + # we don't wanna handle subscripts or commands originating from the debug trap + if [[ "${BASH_SOURCE[1]}" != "$SCRIPT" ]]; then + return + fi + if [[ "$_CISH_STARTED" == true ]]; then + echo "exit code: $_CISH_EXIT_CODE" + fi + _CISH_STARTED=true + echo "${BASH_SOURCE[1]}:${BASH_LINENO[0]} $BASH_COMMAND" +} + +function _cish_on_error() { + _CISH_VALID_EXIT_CODE=$? + _cish_on_command + exit "$_CISH_VALID_EXIT_CODE" +} + +shopt -s extdebug +trap _cish_on_command DEBUG +trap _cish_on_error ERR + +# shellcheck source=/dev/null +source "$SCRIPT"