Skip to content

Instantly share code, notes, and snippets.

@swarupdonepudi
Created February 13, 2020 04:00
Show Gist options
  • Save swarupdonepudi/6577c5a36b0c97e043ce5fb85fac7ba3 to your computer and use it in GitHub Desktop.
Save swarupdonepudi/6577c5a36b0c97e043ce5fb85fac7ba3 to your computer and use it in GitHub Desktop.
New bash programs
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
# Set magic variables for current file & dir
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "info : __dir is ${__dir}"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
echo "info : __file is ${__file}"
__base="$(basename ${__file} .sh)"
echo "info : __base is ${__base}"
#__root of the project depends on the location of this script in the folder structure
__root="$(cd "$(dirname "$(dirname "${__dir}")")" && pwd)"
echo "info : __root is ${__root}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment