added cli options functions

This commit is contained in:
Nathaniel Landau
2015-01-04 00:50:21 -05:00
parent 8f558f6ccd
commit 5ff40a206c
6 changed files with 175 additions and 100 deletions

View File

@@ -9,12 +9,12 @@
# First we locate this script and populate the $SCRIPTPATH variable
# Doing so allows us to source additional files from this utils file.
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
while [ -h "${SOURCE}" ]; do # resolve ${SOURCE} until the file is no longer a symlink
DIR="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
SOURCE="$(readlink "${SOURCE}")"
[[ ${SOURCE} != /* ]] && SOURCE="${DIR}/${SOURCE}" # if ${SOURCE} was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SOURCEPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCEPATH="$( cd -P "$( dirname "${SOURCE}" )" && pwd )"
# Write the list of utility files to be sourced
FILES="
@@ -26,10 +26,10 @@ FILES="
# Source the Utility Files
for file in $FILES
do
if [ -f "$SOURCEPATH/$file" ]; then
source "$SOURCEPATH/$file"
if [ -f "${SOURCE}PATH/${file}" ]; then
source "${SOURCE}PATH/${file}"
else
e_error "$file does not exist. Exiting"
e_error "${file} does not exist. Exiting"
Exit 1
fi
done