Skip to content

Instantly share code, notes, and snippets.

@frontrangerider2004
Created June 24, 2016 15:51
Show Gist options
  • Save frontrangerider2004/b67afca770c264ffab759718fb0b381e to your computer and use it in GitHub Desktop.
Save frontrangerider2004/b67afca770c264ffab759718fb0b381e to your computer and use it in GitHub Desktop.
SCRIPT_NAME="$(basename -- "$0")"
ABS_SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
####################################################################
# setAbsolutePathofDirectory
#
# PARAMS: directory, String
# cd's into the directory and prints the dir name, then cd's back.
####################################################################
function setAbsolutePathofDirectory {
logD "[setAbsolutePathofDirectory]"
if [ ! -d "$1" ]; then
log "[setAbsolutePathofDirectory] Error, supplied dir does not exist!"
printUsage
exit 1
fi
# Safely set the repo directory abs path
MY_DIR="$(cd $1 && pwd)"
cd "$ABS_SCRIPT_PATH"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment