Skip to content
Snippets Groups Projects
Commit 1dcf81c3 authored by Adrien Matta's avatar Adrien Matta :skull_crossbones:
Browse files

- The script now cleanup PATH and LIBRARY_PATH from old addons

        - This allow for a clean reload of the nptool.sh script
        - user can switch between nptool version within a given bash
        sesssion
parent 462a3a3c
No related branches found
No related tags found
No related merge requests found
#! /bin/bash
# remove a given directory to PATH
function np_path_remove {
# Delete path by parts so we can never accidentally remove sub paths
PATH=${PATH//":$1:"/":"} # delete any instances in the middle
PATH=${PATH/#"$1:"/} # delete any instance at the beginning
PATH=${PATH/%":$1"/} # delete any instance in the at the end
}
# remove a given directory to LD_LIBRARY_PATH
function np_ld_remove {
# Delete path by parts so we can never accidentally remove sub paths
LD_LIBRARY_PATH=${LD_LIBRARY_PATH//":$1:"/":"} # delete any instances in the middle
LD_LIBRARY_PATH=${LD_LIBRARY_PATH/#"$1:"/} # delete any instance at the beginning
LD_LIBRARY_PATH=${LD_LIBRARY_PATH/%":$1"/} # delete any instance in the at the end
}
# remove a given directory to DYLD_LIBRARY_PATH
function np_dyld_remove {
# Delete path by parts so we can never accidentally remove sub paths
DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH//":$1:"/":"} # delete any instances in the middle
DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH/#"$1:"/} # delete any instance at the beginning
DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH/%":$1"/} # delete any instance in the at the end
}
CMD="export"
SEP="="
......@@ -30,6 +54,21 @@ else
exit 1
fi
# if NPTOOL already exist, remove old path from PATH and LIBRARY_PATH
if [ ! -z "{$NPTOOL}" ];
then
np_path_remove ${NPTOOL}/NPLib/bin
np_path_remove ${NPTOOL}/NPSimulation/bin
if [ "${NPARCH}" = "Darwin" ] ;
then
np_dyld_remove ${NPTOOL}/NPLib/lib
np_dyld_remove ${NPTOOL}/NPSimulation/lib
else
np_ld_remove ${NPTOOL}/NPLib/lib
np_ld_remove ${NPTOOL}/NPSimulation/lib
fi
fi
# export NPTOOL environment variable
${CMD} NPTOOL${SEP}$SCRIPTPATH
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment