Created
January 19, 2016 11:35
-
-
Save mrinalwadhwa/5d4b462ba40e229617ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -o errexit | |
set -o nounset | |
set -o pipefail | |
is_xcode_cli_tools_installed() { | |
xcode-select -p >/dev/null 2>&1 | |
[[ $? -eq 0 ]] | |
} | |
install_xcode_cli_tools() { | |
local flag='/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress' | |
touch $flag | |
local UPDATE_NAME=$( softwareupdate --list \ | |
| grep '\*.*Command Line' \ | |
| head -n 1 \ | |
| awk -F"*" '{print $2}' \ | |
| sed -e 's/^ *//' \ | |
| tr -d '\n' | |
) | |
softwareupdate --install --verbose "${UPDATE_NAME}" | |
local success=$? | |
rm $flag | |
return $success | |
} | |
main() { | |
is_xcode_cli_tools_installed || install_xcode_cli_tools | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment