diff --git a/snippets/script.template.bash b/snippets/script.template.bash new file mode 100644 index 0000000..4741ece --- /dev/null +++ b/snippets/script.template.bash @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -euo 'pipefail' + +ERROR_GENERIC=1 +ERROR_REQUIRED_TOOL_MISSING=2 + +pre_flight() { + REQUIRED_TOOLS=( + 'xargs' + '…' + ) + for TOOL in ${REQUIRED_TOOLS[@]} + do + if ! ( which "$TOOL" > '/dev/null' ) + then + echo -e "missing required tool: $TOOL" >&2 + exit $ERROR_REQUIRED_TOOL_MISSING + fi + done +} + +pre_flight +# …