Skip to content

Instantly share code, notes, and snippets.

@zhum
zhum / bash-cheatsheet.sh
Last active April 23, 2024 15:58
Bash script sheatsheet
#!/usr/bin/env bash
# shellcheck disable=all
#-------------- options --------------
set -e # stop on any command fail
set -E # generate ERR exception on aliases, functions, and commands in if/while/until conditions
set -u # stop on any unbound variable
set -o pipefail # stop on any fail with pipe
set -o errtrace # print call trace on errors
@zhum
zhum / bashscript-template.sh
Last active May 1, 2023 10:41
Bash script template with usefull things
#!/usr/bin/env bash
#
# YOUR DESCRIPTION HERE
#
#
# check it with https://www.shellcheck.net/
# set -e = FAIL if any command fails
# set -o pipefail = FAIL if any command in the pipe fails
# set -u = FAIL if any variable is used, but not initialized