Last active
April 21, 2016 10:47
-
-
Save kpietru/2ca118cf2182e63bfa1375f527e26381 to your computer and use it in GitHub Desktop.
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
# Magic variables: __FILE__, __DIR__, __BASE__, __ROOT__ | |
bashSource="${BASH_SOURCE[0]}" | |
while [ -h "${bashSource}" ]; do | |
if [[ "${bashSource}" == /* ]]; then | |
bashSource="$(readlink "${bashSource}")" | |
else | |
bashSource="$(dirname "${bashSource}")/$(readlink "${bashSource}")" | |
fi | |
done | |
__FILE__="${bashSource}" | |
__DIR__="$(cd -P "$(dirname "${__FILE__}")" && pwd)" | |
__BASE__="$(basename "${__FILE__}" .sh)" | |
__ROOT__="$(dirname "${__DIR__}")" | |
# Or | |
# Magic variables: __FILE__, __DIR__, __BASE__, __ROOT__ | |
eval 'p=`readlink -f "${BASH_SOURCE[0]}"`;__FILE__="$p";__DIR__=`dirname "$p"`;__BASE__=`basename "$p".sh`;__ROOT__=`dirname "$__DIR__"`' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment