Skip to content

Commit

Permalink
Enable running setup-env from non-bash shells (#319)
Browse files Browse the repository at this point in the history
Signed-off-by: Tal Ben-Nun <talbn@llnl.gov>
  • Loading branch information
tbennun committed Jan 10, 2024
1 parent 608287d commit 5b42702
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmake/Templates/setup-env.sh.in
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 5b42702

Please sign in to comment.