summaryrefslogtreecommitdiffstats
path: root/.setup/installbrew.sh
diff options
context:
space:
mode:
authorTyler Davis <tydavis@gmail.com>2020-12-01 21:33:27 -0800
committerTyler Davis <tydavis@gmail.com>2020-12-01 21:33:27 -0800
commitd14881f98bcbae7a36d3240f5bd785f4e09756d0 (patch)
tree311c97b0e99194cd93a343e32d803470e8fab5b6 /.setup/installbrew.sh
parent7da19fdaf1b561fc8e3730d036b31c4e4f5d1ba8 (diff)
downloaddotfiles-d14881f98bcbae7a36d3240f5bd785f4e09756d0.tar.gz
dotfiles-d14881f98bcbae7a36d3240f5bd785f4e09756d0.zip
brew: update script
Diffstat (limited to '.setup/installbrew.sh')
-rw-r--r--.setup/installbrew.sh17
1 files changed, 14 insertions, 3 deletions
diff --git a/.setup/installbrew.sh b/.setup/installbrew.sh
index 1f9e436..9b30734 100644
--- a/.setup/installbrew.sh
+++ b/.setup/installbrew.sh
@@ -1,6 +1,12 @@
#!/bin/bash
set -u
+# Check if script is run non-interactively (e.g. CI)
+# If it is run non-interactively we should not prompt for passwords.
+if [[ ! -t 0 || -n "${CI-}" ]]; then
+ NONINTERACTIVE=1
+fi
+
# First check if the OS is Linux.
if [[ "$(uname)" = "Linux" ]]; then
HOMEBREW_ON_LINUX=1
@@ -64,6 +70,8 @@ have_sudo_access() {
local -a args
if [[ -n "${SUDO_ASKPASS-}" ]]; then
args=("-A")
+ elif [[ -n "${NONINTERACTIVE-}" ]]; then
+ args=("-n")
fi
if [[ -z "${HAVE_SUDO_ACCESS-}" ]]; then
@@ -72,7 +80,7 @@ have_sudo_access() {
else
SUDO="/usr/bin/sudo"
fi
- if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
+ if [[ -n "${NONINTERACTIVE-}" ]]; then
${SUDO} -l mkdir &>/dev/null
else
${SUDO} -v && ${SUDO} -l mkdir &>/dev/null
@@ -290,7 +298,10 @@ fi
if [[ -z "${HOMEBREW_ON_LINUX-}" ]]; then
have_sudo_access
else
- if [[ -n "${CI-}" ]] || [[ -w "$HOMEBREW_PREFIX_DEFAULT" ]] || [[ -w "/home/linuxbrew" ]] || [[ -w "/home" ]]; then
+ if [[ -n "${NONINTERACTIVE-}" ]] ||
+ [[ -w "$HOMEBREW_PREFIX_DEFAULT" ]] ||
+ [[ -w "/home/linuxbrew" ]] ||
+ [[ -w "/home" ]]; then
HOMEBREW_PREFIX="$HOMEBREW_PREFIX_DEFAULT"
else
trap exit SIGINT
@@ -471,7 +482,7 @@ if should_install_command_line_tools; then
ohai "The Xcode Command Line Tools will be installed."
fi
-if [[ -t 0 && -z "${CI-}" ]]; then
+if [[ -z "${NONINTERACTIVE-}" ]]; then
wait_for_user
fi