diff --git a/iocBoot/iocxxx/softioc/xxx.sh b/iocBoot/iocxxx/softioc/xxx.sh
index 44f280fbbd11c65b51915f255ce66e72f03eba80..b5fae26c1c2fdcaae723e5058082ef296e4d6e9f 100755
--- a/iocBoot/iocxxx/softioc/xxx.sh
+++ b/iocBoot/iocxxx/softioc/xxx.sh
@@ -46,7 +46,7 @@ SELECTION=$1
 if [ -z "$IOC_STARTUP_DIR" ]
 then
     # If no startup dir is specified, use the directory above the script's directory
-    IOC_STARTUP_DIR=`dirname $BASH_SOURCE`/..
+    IOC_STARTUP_DIR=`dirname ${SNAME}`/..
 	IOC_CMD="../../bin/${EPICS_HOST_ARCH}/${IOC_BINARY} st.cmd.Linux"
 else
 	IOC_CMD="${IOC_STARTUP_DIR}/../../bin/${EPICS_HOST_ARCH}/${IOC_BINARY} ${IOC_STARTUP_DIR}/st.cmd.Linux"