brew.rb: Don't ask xcrun for output if no CLT is installed (#334)

This avoids `xcrun` popups when installing Homebrew on a non-Xcode
non-CLT machine.
This commit is contained in:
Elliot Saba 2016-06-08 05:53:10 -07:00 committed by Martin Afanasjew
parent 8d64b6a02d
commit 2ca6dbbe9d

View File

@ -137,7 +137,8 @@ export HOMEBREW_USER_AGENT_CURL
if [[ -n "$HOMEBREW_OSX" ]] if [[ -n "$HOMEBREW_OSX" ]]
then then
if [[ "$('/usr/bin/xcode-select' --print-path)" = "/" ]] XCODE_SELECT_PATH=$('/usr/bin/xcode-select' --print-path 2>/dev/null)
if [[ "$XCODE_SELECT_PATH" = "/" ]]
then then
odie <<EOS odie <<EOS
Your xcode-select path is currently set to '/'. Your xcode-select path is currently set to '/'.
@ -149,15 +150,20 @@ Otherwise, you should:
EOS EOS
fi fi
XCRUN_OUTPUT="$(/usr/bin/xcrun clang 2>&1)" # Don't check xcrun if Xcode and the CLT aren't installed, as that opens
XCRUN_STATUS="$?" # a popup window asking the user to install the CLT
if [[ -n "$XCODE_SELECT_PATH" ]]
if [[ "$XCRUN_STATUS" -ne 0 && "$XCRUN_OUTPUT" = *license* ]]
then then
odie <<EOS XCRUN_OUTPUT="$(/usr/bin/xcrun clang 2>&1)"
XCRUN_STATUS="$?"
if [[ "$XCRUN_STATUS" -ne 0 && "$XCRUN_OUTPUT" = *license* ]]
then
odie <<EOS
You have not agreed to the Xcode license. Please resolve this by running: You have not agreed to the Xcode license. Please resolve this by running:
sudo xcodebuild -license sudo xcodebuild -license
EOS EOS
fi
fi fi
fi fi