From e0ed9a6e525f23df3ce1d42cf9ee9843ea558bc1 Mon Sep 17 00:00:00 2001 From: Tal Ben-Nun Date: Wed, 10 Jan 2024 05:17:08 -0800 Subject: [PATCH] Enable running setup-env from non-bash shells (#319) Signed-off-by: Tal Ben-Nun [ROCm/rocprofiler-systems commit: 5b4270229916250ffca054747ed960f31fbf5683] --- .../rocprofiler-systems/cmake/Templates/setup-env.sh.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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