diff --git a/set_env.sh b/set_env.sh
index 1d911c6a74d52d2b1a76237a76fba6cc702d1565..6a4a0b55636a1cb1492b98c26ce58401f449da52 100755
--- a/set_env.sh
+++ b/set_env.sh
@@ -24,7 +24,7 @@ if [ -z $DESIGN_ROOT ]; then
     source $DESIGN_ROOT/set_env.sh
 else
     # Set Environment Variable for this Repository
-    export ACC_ENGINE_DIR="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
+    export ACC_ENGINE_DIR="$(cd -P "$(dirname "${BASH_SOURCE[0]:-${(%):-%x}}")" && pwd)"
 
     # If this Repo is root of workspace
     if [ $ACC_ENGINE_DIR = $DESIGN_ROOT ]; then