From aff64733a7b1f1355050bf18b1d9e410b7c139e3 Mon Sep 17 00:00:00 2001 From: Nathaniel Landau Date: Mon, 27 Dec 2021 16:12:14 -0500 Subject: [PATCH] don't add homebrew to PATH unless macOS --- template_standalone.sh | 17 +++++++++++++---- utilities/macOS.bash | 17 +++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/template_standalone.sh b/template_standalone.sh index c4d6950..de0c919 100755 --- a/template_standalone.sh +++ b/template_standalone.sh @@ -493,12 +493,21 @@ _homebrewPath_() { ! declare -f "_setPATH_" &>/dev/null && fatal "${FUNCNAME[0]} needs function _setPATH_" - if _setPATH_ "/usr/local/bin" "/opt/homebrew/bin"; then - return 0 + if _uname=$(command -v uname); then + if "${_uname}" | tr '[:upper:]' '[:lower:]' | grep -q 'darwin'; then + if _setPATH_ "/usr/local/bin" "/opt/homebrew/bin"; then + return 0 + else + return 1 + fi + fi else - return 1 + if _setPATH_ "/usr/local/bin" "/opt/homebrew/bin"; then + return 0 + else + return 1 + fi fi - } _parseOptions_() { diff --git a/utilities/macOS.bash b/utilities/macOS.bash index e932bc8..37d0312 100644 --- a/utilities/macOS.bash +++ b/utilities/macOS.bash @@ -96,10 +96,19 @@ _homebrewPath_() { ! declare -f "_setPATH_" &>/dev/null && fatal "${FUNCNAME[0]} needs function _setPATH_" - if _setPATH_ "/usr/local/bin" "/opt/homebrew/bin"; then - return 0 + if _uname=$(command -v uname); then + if "${_uname}" | tr '[:upper:]' '[:lower:]' | grep -q 'darwin'; then + if _setPATH_ "/usr/local/bin" "/opt/homebrew/bin"; then + return 0 + else + return 1 + fi + fi else - return 1 + if _setPATH_ "/usr/local/bin" "/opt/homebrew/bin"; then + return 0 + else + return 1 + fi fi - }