aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2023-09-26 11:51:32 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2023-09-26 11:51:32 -0400
commit6005e86bb3b5b2498b5bca0753a8c399f40463c4 (patch)
treeb17992e97b4ab774aa658e551401c110ae4f7366
parent5a182ff070218077f61c29b163dd85962cdabc81 (diff)
downloadspexmgr-6005e86bb3b5b2498b5bca0753a8c399f40463c4.tar.gz
Do not allow shell execution as a script
* Do not duplicate IDL_DIR if IDL_PATH_OLD was unset
-rwxr-xr-xbin/spexactivate18
1 files changed, 16 insertions, 2 deletions
diff --git a/bin/spexactivate b/bin/spexactivate
index a466778..e6d57f3 100755
--- a/bin/spexactivate
+++ b/bin/spexactivate
@@ -1,12 +1,22 @@
#!/usr/bin/env bash
# vim: tabstop=4 shiftwidth=4 expandtab
+usage() {
+ echo "usage: source $(basename $0) {release}" >&2
+}
+
+if [ "${BASH_SOURCE[0]}" -ef "$0" ]; then
+ echo "ERROR: This script is not designed to be executed." >&2
+ usage
+ exit 1
+fi
+
topdir="$( dirname $(cd $(dirname ${BASH_SOURCE[0]}) && pwd) )"
datadir="${topdir}/share"
spexdir="${topdir}/spex"
spextool_version="$1"
if [ -z "$spextool_version" ]; then
- echo "usage: source $(basename $0) {release}" >&2
+ usage
return 1
fi
@@ -27,6 +37,10 @@ fi
paths="+${datadir}:+${root}"
if ! [[ "$IDL_PATH" =~ .*"$paths".* ]]; then
unset IDL_PATH
- IDL_PATH="${paths}:${IDL_PATH_OLD}:+${IDL_DIR}"
+ if [[ "$IDL_PATH_OLD" == "+${IDL_DIR}" ]]; then
+ IDL_PATH="${paths}:${IDL_PATH_OLD}"
+ else
+ IDL_PATH="${paths}:${IDL_PATH_OLD}:+${IDL_DIR}"
+ fi
fi
export IDL_PATH