diff --git a/open_spiel/scripts/install.sh b/open_spiel/scripts/install.sh index 6fbda281c4..51e10d4858 100755 --- a/open_spiel/scripts/install.sh +++ b/open_spiel/scripts/install.sh @@ -34,7 +34,9 @@ ${PYBIN} --version MYDIR="$(dirname "$(realpath "$0")")" function check_install_python() { - output=$(brew list --versions | grep "python ${OS_PYTHON_VERSION}") + # Need the trap here to make sure the return value of grep being 1 doesn't cause set -e to fail + # https://stackoverflow.com/questions/77047127/bash-capture-stderr-of-a-function-while-using-trap + trap 'ret=0; output=$(brew list --versions | grep "python ${OS_PYTHON_VERSION}") || ret="$?"; trap - RETURN' RETURN if [[ "$output" = "" ]]; then brew install "python@${OS_PYTHON_VERSION}" fi