Little bit of simple cleanup

This commit is contained in:
Luke 2019-10-06 16:19:34 -07:00
parent 8c66602158
commit 588b54c79a

View file

@ -2,12 +2,6 @@
##################################################################### #####################################################################
# If we have a path element, strip it then add it in the new location # If we have a path element, strip it then add it in the new location
##################################################################### #####################################################################
function testDirPathStripAdd() {
if [ -d "$1" ]; then
pathStripAdd "$1"
fi
}
function pathStripAdd() { function pathStripAdd() {
pathStrip "$1" pathStrip "$1"
if [[ "$2" == "front" ]]; then if [[ "$2" == "front" ]]; then
@ -79,39 +73,40 @@ fi
# Load information that is in any extra random installed directory. # Load information that is in any extra random installed directory.
__LOAD_DIRS=(/opt/mate /opt/makemkv /opt/ffmpeg $HOME/.gem/ruby/2.5.0 /opt/icestorm) __LOAD_DIRS=(/opt/mate /opt/makemkv /opt/ffmpeg $HOME/.gem/ruby/2.5.0 /opt/icestorm)
for DIR_EXPAND in ${__LOAD_DIRS[*]} for DIR_EXPAND in ${__LOAD_DIRS[*]}; do
do
loadDirectory $DIR_EXPAND loadDirectory $DIR_EXPAND
done done
unset DIR_EXPAND __LOAD_DIRS unset DIR_EXPAND __LOAD_DIRS
echo $PKG_CONFIG_PATH ## This block was a legacy bit from when I spent so much time screwing around
echo $LD_RUN_PATH # with Macports and had really janky enviornment varables. I don't need this
echo $LD_LIBRARY_PATH # anymore because the loader is now mature enough to not randomly throw garbage
# CLEAN these variables # into the enviornment variables. This code is left simply for legacy purposes
__VAR_PTR_LST=(PKG_CONFIG_PATH LD_RUN_PATH LD_LIBRARY_PATH) # as an example of what you end up writing if you really have no idea what your
for __VAR_PTR in ${__VAR_PTR_LST[*]} # doing (also known as learning!).
do ## CLEAN these variables
# get the value in the pointer #__VAR_PTR_LST=(PKG_CONFIG_PATH LD_RUN_PATH LD_LIBRARY_PATH)
eval __VAR_VAL=\$$__VAR_PTR #for __VAR_PTR in ${__VAR_PTR_LST[*]}
if [ ${#__VAR_VAL} -gt 0 ]; then #do
# Strip ending : or leading : if exists. # # get the value in the pointer
if [ ${__VAR_VAL: -1} == ":" ]; then # eval __VAR_VAL=\$$__VAR_PTR
__VAR_VAL=${__VAR_VAL:0:-1} # if [ ${#__VAR_VAL} -gt 0 ]; then
fi # # Strip ending : or leading : if exists.
if [ ${__VAR_VAL:0:1} == ":" ]; then # if [ ${__VAR_VAL: -1} == ":" ]; then
__VAR_VAL=${__VAR_VAL:1} # __VAR_VAL=${__VAR_VAL:0:-1}
fi # fi
while [[ $__VAR_VAL == *"::"* ]]; do # if [ ${__VAR_VAL:0:1} == ":" ]; then
__VAR_VAL=${__VAR_VAL/::/:} # __VAR_VAL=${__VAR_VAL:1}
done # fi
while [[ $__VAR_VAL == *"/:"* ]]; do # while [[ $__VAR_VAL == *"::"* ]]; do
__VAR_VAL=${__VAR_VAL/\/:/:} # __VAR_VAL=${__VAR_VAL/::/:}
done # done
# save the cleaned result # while [[ $__VAR_VAL == *"/:"* ]]; do
eval $__VAR_PTR=$__VAR_VAL # __VAR_VAL=${__VAR_VAL/\/:/:}
#echo $__VAR_PTR "=" $__VAR_VAL # done
fi # # save the cleaned result
done # eval $__VAR_PTR=$__VAR_VAL
unset __VAR_PTR_LST __VAR_PTR __VAR_VAL # #echo $__VAR_PTR "=" $__VAR_VAL
# fi
#done
#unset __VAR_PTR_LST __VAR_PTR __VAR_VAL