File tree Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Expand file tree Collapse file tree 3 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,15 @@ has_command () {
25
25
26
26
read_input_with_default () {
27
27
echo -n " > "
28
- read READ_INPUT_RETURN
28
+ # The installer script is usually run by "curl ... | bash", which means that
29
+ # stdin is not a tty but the script content itself. In that case, "read" builtin
30
+ # command receives EOF immediately. To avoid that, we use /dev/tty as stdin explicitly.
31
+ # SWIFTLY_READ_FROM_STDIN is used for testing interactive input
32
+ if [[ -t 0 ]] || [[ ${SWIFTLY_READ_FROM_STDIN+set} == " set" ]]; then
33
+ read READ_INPUT_RETURN
34
+ else
35
+ read READ_INPUT_RETURN < /dev/tty
36
+ fi
29
37
30
38
if [ -z " $READ_INPUT_RETURN " ]; then
31
39
READ_INPUT_RETURN=" $1 "
Original file line number Diff line number Diff line change 2
2
3
3
# Common utility functionality used in the various bash tests for swiftly-install.sh.
4
4
5
+ export SWIFTLY_READ_FROM_STDIN=1
6
+
5
7
has_command () {
6
8
command -v " $1 " > /dev/null
7
9
}
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ echo "$DUMMY_CONFIG_CONTENTS" > "$SWIFTLY_HOME_DIR/config.json"
27
27
mkdir " $SWIFTLY_HOME_DIR /toolchains/5.7.3"
28
28
29
29
# Attempt the same installation, but decline to overwrite.
30
- printf " 1\nn\n" | ./swiftly-install.sh
30
+ printf " 1\nn\n" | ./swiftly-install.sh
31
31
32
32
if ! has_command " swiftly" ; then
33
33
test_fail " Can't find swiftly on the PATH"
@@ -43,7 +43,7 @@ if [[ ! -d "$SWIFTLY_HOME_DIR/toolchains/5.7.3" ]]; then
43
43
fi
44
44
45
45
# Attempt the same installation, but overwrite this time.
46
- printf " 1\ny\n" | ./swiftly-install.sh
46
+ printf " 1\ny\n" | ./swiftly-install.sh
47
47
48
48
if ! has_command " swiftly" ; then
49
49
test_fail " Can't find swiftly on the PATH"
You can’t perform that action at this time.
0 commit comments