Skip to content

Instantly share code, notes, and snippets.

@ivan-pinatti
Created December 22, 2020 16:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivan-pinatti/ddcf83fd7621c996167b3f2933416a38 to your computer and use it in GitHub Desktop.
Save ivan-pinatti/ddcf83fd7621c996167b3f2933416a38 to your computer and use it in GitHub Desktop.
BASH Script Skeleton - #bash #script #shell #skeleton
#!/usr/bin/env bash
: ' Insert the description of the script here
# exit(s) status code(s)
0 - success
1 - fail
'
# check if debug flag is set
if [ "${DEBUG}" = true ]; then
set -x # enable print commands and their arguments as they are executed.
export # show all declared variables (includes system variables)
whoami # print current user
else
# unset if flag is not set
unset DEBUG
fi
# bash default parameters
set -o errexit # make your script exit when a command fails
set -o pipefail # exit status of the last command that threw a non-zero exit code is returned
set -o nounset # exit when your script tries to use undeclared variables
# check binaries
__BASENAME=$(which basename)
__CURL=$(which curl)
__DATE=$(which date)
# parameters
__date=${1:-"4 weeks ago"}
# variables
readonly __date_epoch=$(${__DATE} --date="${__date}" +%s)
# functions
function my_function {
# parameters
local __text="${1:-}"
} # end of my_function
# flow
# insert your code here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment