I am creating a bash script to setup a development environment. As part of my script I need to install Xcode Command Line Tools and I don't want the script to continue execution until the installation has been completed.
When I run:
xcode-select --install
It prints that an install has been requested or that it has already been installed. I want to be able to wait until the message changes to already being installed.
The relevant part of my script is as follows:
check="$(xcode-\select --install)"
echo "$check"
str="xcode-select: note: install requested for command line developer tools\n"
while [[ "$check" == "$str" ]];
do
check="$(xcode-\select --install)"
sleep 1
done
Unfortunately $check is always empty because xcode-select --install does not return anything and instead echoes the message to the terminal.
xcode-select --install 2>&1help?check="$(xcode-\select --install)", shouldn't that becheck="$(xcode-select --install)"? in other words, no backslash between the-andsinxcode-select.selectis a reserved word in bash