Skip to content

Instantly share code, notes, and snippets.

@rot26
Last active July 14, 2019 21:06
Show Gist options
  • Save rot26/d8565404c933cef0e8874f0ccf775557 to your computer and use it in GitHub Desktop.
Save rot26/d8565404c933cef0e8874f0ccf775557 to your computer and use it in GitHub Desktop.
[default bash script] #default #fav #bash #shell
#!/usr/bin/env bash
# SheBang defaults to environment's bash
# Set errexit / Do not continue on errors
set -e;
# Set bash debug
if [[ "$@" == *"--debug"* ]] || [ ${BASH_DEBUG} ]; then
export BASH_DEBUG=true;
set -x;
fi
# Reference Path of this script
SCRIPT_PATH="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
# Reference path where you will run script paths from
SCRIPT_ROOT="$(cd "${SCRIPT_PATH}/.." && pwd)"
# All paths are referenced from $SCRIPT_ROOT unless otherwise specified
cd "${SCRIPT_ROOT}"
# Replace script here
echo "SCRIPT_PATH= ${SCRIPT_PATH}"
echo "SCRIPT_ROOT= ${SCRIPT_ROOT}"
echo "CWD = $(pwd)"
echo "BASH_DEBUG = ${BASH_DEBUG}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment