diff options
author | Graham Christensen <graham@grahamc.com> | 2017-07-13 19:03:35 -0400 |
---|---|---|
committer | Graham Christensen <graham@grahamc.com> | 2017-07-14 12:11:30 -0400 |
commit | 12f6bb33d2cf56e8adf482950734a9af5f78a496 (patch) | |
tree | 9b9779bb8962f4535521ead1fb2d6a1ae1b882ca | |
parent | ce2281e6d86aa1b461dd27f86b2a71145e85ac8d (diff) |
If there is no TTY, also skip verbose sudo messages
-rw-r--r-- | scripts/install-darwin-multi-user.sh | 36 | ||||
-rwxr-xr-x | 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 <<EOF +This script is going to call sudo a lot. Normally, it would show you +exactly what commands it is running and why. However, the script is +run in a headless fashion, like this: + + $ curl https://nixos.org/nix/install | sh + +or maybe in a CI pipeline. Because of that, we're going to skip the +verbose output in the interest of brevity. + +If you would like to +see the output, try like this: + + $ curl -o install-nix https://nixos.org/nix/install + $ sh ./install-nix + +EOF + return 0 + fi + cat <<EOF This script is going to call sudo a lot. Every time we do, it'll output exactly what it'll do, and why. diff --git a/tests/install-darwin.sh b/tests/install-darwin.sh index 3f64944ef..eb251fa39 100755 --- a/tests/install-darwin.sh +++ b/tests/install-darwin.sh @@ -91,5 +91,6 @@ verify echo -n "" | PINCH_ME_IM_SILLY=true ./install verify test -e /nix/store/.silly-hint + cleanup ) |