From c6b803ea99a5947213c390f858e048eef760f62e Mon Sep 17 00:00:00 2001 From: Sabine Schmaltz Date: Mon, 3 Apr 2023 19:26:54 +0200 Subject: [PATCH 1/5] explicitly connect /dev/tty. Allows running via sh --- shell/install.sh | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/shell/install.sh b/shell/install.sh index 8ffdf864ac3..066b5703e75 100755 --- a/shell/install.sh +++ b/shell/install.sh @@ -186,6 +186,14 @@ usage() { echo "using '--fresh' or '--dev'" } +R= +prompt() { + # expects to be called as prompt "Do you want to do this? [Y/n]" + printf "$1" + read R Date: Mon, 3 Apr 2023 19:57:55 +0200 Subject: [PATCH 2/5] Update shell/install.sh Co-authored-by: Kate --- shell/install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/shell/install.sh b/shell/install.sh index 066b5703e75..f848c17325a 100755 --- a/shell/install.sh +++ b/shell/install.sh @@ -367,7 +367,6 @@ if [ -n "$RESTORE" ]; then fi if [ "$NOBACKUP" = 1 ]; then prompt "## This will clear $OPAM and $OPAMROOT. Continue ? [Y/n] " - R=$? case "$R" in ""|"y"|"Y"|"yes") xsudo rm -f "$OPAM" From 8e657065f4ff714313e908155a701ca606fadcfe Mon Sep 17 00:00:00 2001 From: Sabine Schmaltz Date: Wed, 5 Apr 2023 18:13:58 +0200 Subject: [PATCH 3/5] conditionally connect /dev/tty only when environment var TTY=1 --- shell/install.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/shell/install.sh b/shell/install.sh index f848c17325a..3f9de7c4981 100755 --- a/shell/install.sh +++ b/shell/install.sh @@ -186,14 +186,20 @@ usage() { echo "using '--fresh' or '--dev'" } +# Conditionally connect /dev/tty when +# the environment variable TTY is set to 1 +TTY="${TTY-0}" R= prompt() { - # expects to be called as prompt "Do you want to do this? [Y/n]" + # expects to be called as prompt "Do you want to do this? [Y/n] " printf "$1" - read R Date: Mon, 3 Apr 2023 19:07:03 +0200 Subject: [PATCH 4/5] run opam init for a fresh install --- shell/install.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/shell/install.sh b/shell/install.sh index 3f9de7c4981..0daec87cbde 100755 --- a/shell/install.sh +++ b/shell/install.sh @@ -478,6 +478,13 @@ echo "## opam $VERSION installed to $BINDIR" if [ ! "$FRESH" = 1 ]; then echo "## Converting the opam root format & updating" "$BINDIR/opam" init --reinit -ni +else + echo "## Running opam init for this fresh install" + if [ "$TTY" = 1 ]; then + "$BINDIR/opam" init Date: Fri, 21 Apr 2023 09:52:30 +0200 Subject: [PATCH 5/5] toggle whether to run opam init by environment variable INIT --- shell/install.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/shell/install.sh b/shell/install.sh index 0daec87cbde..4eee4cb1791 100755 --- a/shell/install.sh +++ b/shell/install.sh @@ -200,6 +200,8 @@ prompt() { fi } +INIT="${INIT-0}" + RESTORE= NOBACKUP= FRESH= @@ -479,11 +481,13 @@ if [ ! "$FRESH" = 1 ]; then echo "## Converting the opam root format & updating" "$BINDIR/opam" init --reinit -ni else - echo "## Running opam init for this fresh install" - if [ "$TTY" = 1 ]; then - "$BINDIR/opam" init