chore(snippets): add bash script template

This commit is contained in:
Michele Cereda
2024-12-08 17:59:35 +01:00
parent fcf3fe6588
commit 0aab30df0c

View File

@@ -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
# …