From 12f6bb33d2cf56e8adf482950734a9af5f78a496 Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Thu, 13 Jul 2017 19:03:35 -0400 Subject: [PATCH] If there is no TTY, also skip verbose sudo messages --- scripts/install-darwin-multi-user.sh | 36 +++++++++++++++++++++++++--- tests/install-darwin.sh | 1 + 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/scripts/install-darwin-multi-user.sh b/scripts/install-darwin-multi-user.sh index b1d258e0c..cde40a7f2 100644 --- a/scripts/install-darwin-multi-user.sh +++ b/scripts/install-darwin-multi-user.sh @@ -49,6 +49,14 @@ else readonly IS_HEADLESS='yes' fi +headless() { + if [ "$IS_HEADLESS" = "yes" ]; then + return 0 + else + return 1 + fi +} + contactme() { echo "We'd love to help if you need it." echo "" @@ -179,7 +187,7 @@ failure() { ui_confirm() { _textout "$GREEN$GREEN_UL" "$1" - if [ "$IS_HEADLESS" = "yes" ]; then + if headless; then echo "No TTY, assuming you would say yes :)" return 0 fi @@ -221,9 +229,10 @@ __sudo() { _sudo() { local expl="$1" shift - if __sudo "$expl" "$*"; then - sudo "$@" + if ! headless; then + __sudo "$expl" "$*" fi + sudo "$@" } @@ -620,6 +629,27 @@ EOF chat_about_sudo() { header "let's talk about sudo" + if headless; then + cat <