diff --git a/projects/rocprofiler-systems/cmake/Templates/setup-env.sh.in b/projects/rocprofiler-systems/cmake/Templates/setup-env.sh.in index a234e0551a..ced7facad5 100644 --- a/projects/rocprofiler-systems/cmake/Templates/setup-env.sh.in +++ b/projects/rocprofiler-systems/cmake/Templates/setup-env.sh.in @@ -1,6 +1,11 @@ #!/usr/bin/env bash -BASEDIR=$(dirname ${BASH_SOURCE[0]}) +if [ -z "$BASH_SOURCE" ]; then + # If not running bash, try to obtain directory with $0 + BASEDIR="$( cd "$(dirname "$0")"; pwd -P )" +else + BASEDIR=$(dirname ${BASH_SOURCE[0]}) +fi command -v realpath &> /dev/null && BASEDIR=$(realpath ${BASEDIR}/../..) || BASEDIR=$(cd ${BASEDIR}/../.. && pwd) if [ ! -d "${BASEDIR}" ]; then