Last active
November 28, 2022 22:14
-
-
Save nickistre/a2591a358f755ef101d870be125e591b to your computer and use it in GitHub Desktop.
Helpfull BASH script stuff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# From: https://stackoverflow.com/a/246128 | |
# Basic script path information | |
SOURCE=${BASH_SOURCE[0]} | |
while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | |
K1_BIN_DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd ) | |
SOURCE=$(readlink "$SOURCE") | |
[[ $SOURCE != /* ]] && SOURCE=$K1_BIN_DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | |
done | |
SOURCE_PATH=$(dirname $SOURCE) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment