diff --git a/etc/bashrc b/etc/bashrc
index 0e88166e7..87e5606f2 100644
--- a/etc/bashrc
+++ b/etc/bashrc
@@ -42,8 +42,8 @@ export WM_PROJECT_VERSION=dev
 #
 # Please set to the appropriate path if the default is not correct.
 #
-[ $BASH_SOURCE ] && \
-export FOAM_INST_DIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) || \
+[ ${BASH_SOURCE:-$0} ] && \
+export FOAM_INST_DIR=$(cd $(dirname ${BASH_SOURCE:-$0})/../.. && pwd -P) || \
 export FOAM_INST_DIR=$HOME/$WM_PROJECT
 # export FOAM_INST_DIR=~$WM_PROJECT
 # export FOAM_INST_DIR=/opt/$WM_PROJECT
