Created
August 13, 2013 12:06
-
-
Save skiold/6220454 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
# | |
# Determines the absolute path to the running script. This is useful for | |
# needing to muck around in the running directory when the script has been | |
# called using a relative path | |
# | |
getScriptAbsolutePath() { | |
if [[ ${0:0:1} == '/' ]]; then | |
# If the script was called absolutely | |
absPath=${0} | |
else | |
# If the script was called relatively, strip the . off the front | |
script=`echo ${0} | sed 's/\.\?\(.*\)$/\1/'` | |
absPath="$(pwd)/${script}" | |
fi | |
# Strip the script filename off the end | |
absPath=`echo ${absPath} | sed 's/\(.*\/\).*\$/\1/'` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment