From 0115556db7b8447d6c66e48059f9b674ba74ea89 Mon Sep 17 00:00:00 2001 From: xvzc <45588457+xvzc@users.noreply.github.com> Date: Sat, 6 Jan 2024 18:16:22 +0900 Subject: [PATCH] Update install.sh --- install.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index ed22152..4bd8bf9 100755 --- a/install.sh +++ b/install.sh @@ -32,20 +32,21 @@ check-or-install-xcode() { } check-or-install-brew() { - if type brew >/dev/null 2>&1; then - echo "Found brew at $(whereis brew). Skipping install." - else - echo "homdbrew not found. installing.." + if ! /opt/homebrew/bin/brew shellenv 2>&1; then + echo "homdbrew not found. installing.." require-sudo - /bin/bash -c \ - "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" && - eval "$(/opt/homebrew/bin/brew shellenv)" - fi - - if [ $? -ne 0 ]; then - error "Failed to install brew" + /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" + if [ $? -ne 0 ]; then + error "Failed to install brew" + fi + else + echo "Found brew at $(whereis brew). Skipping install." fi + + if ! eval "$(/opt/homebrew/bin/brew shellenv)"; then + error "Failed to run brew shellenv" + fi } check-or-install-chezmoi() {