Skip to content

Commit 502fd1c

Browse files
fix: check for both python3 and python in exec-env (#78)
Co-authored-by: James Hegedus <jthegedus@hey.com>
1 parent d13787e commit 502fd1c

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

bin/exec-env

+8-13
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,17 @@
22

33
set -eo pipefail
44

5-
current_script_dir="$(
6-
cd -- "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1
7-
pwd -P
8-
)"
9-
plugin_dir="$(dirname "$current_script_dir")"
10-
11-
# shellcheck source=../lib/utils.bash
12-
source "${plugin_dir}/lib/utils.bash"
13-
14-
if [[ ! -x "$(command -v python)" ]]; then
15-
log_failure_and_exit "Python not found and is required for gcloud. Might I suggest https://github.com/danhper/asdf-python"
5+
if [[ -x "$(command -v python3)" ]]; then
6+
python_cmd="python3"
7+
elif [[ -x "$(command -v python)" ]]; then
8+
python_cmd="python"
9+
else
10+
printf "🚨 %s\\n" "Python not found and is required for gcloud. Might I suggest https://github.com/danhper/asdf-python"
11+
exit 1
1612
fi
1713

1814
# credit: https://unix.stackexchange.com/a/56846/397902
1915
if [ -z "${CLOUDSDK_PYTHON:+1}" ]; then
2016
# undefined or defined and empty
21-
python_sdk="$(command -v python)"
22-
export CLOUDSDK_PYTHON=${python_sdk}
17+
export CLOUDSDK_PYTHON="$python_cmd"
2318
fi

0 commit comments

Comments
 (0)