confirm() returned yes whenever stdin was not a tty, so `dotup < /dev/null` in a terminal drew the picker on /dev/tty and then installed without asking. It now opens /dev/tty the way cmd_pick does and reads the answer there; it auto-approves only when no terminal exists at all. pty test plus a mutation (ISSUE-9).
12 lines
386 B
Plaintext
12 lines
386 B
Plaintext
# what: confirm() decides on `[ -t 0 ]` again instead of opening /dev/tty
|
|
# why: `dotup < /dev/null` in a terminal picks, then installs with no [y/N] (ISSUE-9)
|
|
# kills: stdin /dev/null with a terminal still asks [y/N]
|
|
# run: unit
|
|
<<<OLD
|
|
(exec 3</dev/tty) 2>/dev/null || return 0
|
|
printf '\n install? [y/N] ' >&2
|
|
<<<NEW
|
|
[ -t 0 ] || return 0
|
|
printf '\n install? [y/N] ' >&2
|
|
<<<END
|