Skip to content

Instantly share code, notes, and snippets.

View Ithanil's full-sized avatar

Jan Kessler Ithanil

View GitHub Profile
@Ithanil
Ithanil / bash-template.sh
Last active July 11, 2024 08:43 — forked from m-radzikowski/script-template.sh
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/bin/bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
local code=${1-0} # specify exit code when used as alternative to die()
cat <<EOF