From 72f0ae906f7dba4f5b0b37b461e4238abe4cbd12 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 10 Oct 2019 11:12:57 -0400 Subject: [PATCH] Fix gam-install.sh on Cloud Shell and MacOS 10.12 --- src/gam-install.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gam-install.sh b/src/gam-install.sh index b1dcd083..9af89f51 100755 --- a/src/gam-install.sh +++ b/src/gam-install.sh @@ -83,8 +83,13 @@ echo -e '\x1B[0m' version_gt() { +# MacOS < 10.13 doesn't support sort -V +echo "" | sort -V > /dev/null 2>&1 +vsort_failed=$? if [ "${1}" = "${2}" ]; then true +elif $vsort_failed; then + false else test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" fi @@ -184,11 +189,16 @@ try: except KeyError: print('ERROR: assets value not found in JSON value of:\n\n%s' % release)" -pycmd="python" +pycmd="python3" $pycmd -V >/dev/null 2>&1 rc=$? if (( $rc != 0 )); then - pycmd="python3" + pycmd="python" +fi +$pycmd -V >/dev/null 2>&1 +rc=$? +if (( $rc != 0 )); then + pycmd="python2" fi $pycmd -V >/dev/null 2>&1 rc=$?