Skip to content

Commit 51a497d

Browse files
authored
handle no-tty case in gum_func with our old/better error (#115)
* handle no-tty case in gum_func * good error message * cleanup
1 parent 5ae1479 commit 51a497d

File tree

1 file changed

+3
-19
lines changed

1 file changed

+3
-19
lines changed

install.sh

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,25 +162,6 @@ prepare() {
162162
fi
163163
}
164164

165-
gum_no_tty() {
166-
cmd="$1"
167-
while test "$1" != -- -a -n "$1"; do
168-
shift
169-
done
170-
if test -n "$1"; then shift; fi # remove the --
171-
case "$cmd" in
172-
format|style)
173-
echo "$@";;
174-
confirm)
175-
if test -n "$TEA_YES"; then
176-
echo "tea: error: no tty detected, re-run with \`YES=1\` set" >&2
177-
return 1
178-
fi;;
179-
*)
180-
"$@";;
181-
esac
182-
}
183-
184165
get_gum() {
185166
if command -v gum >/dev/null 2>&1; then
186167
TEA_GUM=gum
@@ -218,6 +199,9 @@ gum_func() {
218199
$TEA_GUM "$@" --timeout=1ms --default=yes
219200
set -e
220201
return 0
202+
elif test ! -t 1; then
203+
echo "tea: error: no tty detected, re-run with \`TEA_YES=1\` set" >&2
204+
return 1
221205
fi;;
222206
spin)
223207
if test ! -t 1; then

0 commit comments

Comments
 (0)