Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

declare BASEDIR #98

Open
virgilwashere opened this issue Apr 13, 2019 · 0 comments
Open

declare BASEDIR #98

virgilwashere opened this issue Apr 13, 2019 · 0 comments

Comments

@virgilwashere
Copy link

virgilwashere commented Apr 13, 2019

BASEDIR=$(dirname "$BASH_SOURCE")
cd $BASEDIR/../
BASEDIR=$( pwd )

Use this for a assigning script path:

declare BASEDIR
BASEDIR="$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
# for full symlink resolution
# BASEDIR="$( realpath -qs "$( cd "$( dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd )")"

And possibly this at the start of bash scripts.

# "unofficial" bash strict mode
# See: http://redsymbol.net/articles/unofficial-bash-strict-mode
set -o errexit  # Exit when simple command fails               'set -e'
set -o errtrace # Exit on error inside any functions or subshells.
set -o nounset  # Trigger error when expanding unset variables 'set -u'
set -o pipefail # Do not hide errors within pipes              'set -o pipefail'
# set -o xtrace # Display expanded command and arguments       'set -x'
IFS=$'\n\t'     # Split words on \n\t rather than spaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant