fix: [y/N] is asked on the terminal, not on stdin

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).
This commit is contained in:
bcherb2 committed 2026-11-18 02:13:00 -05:00
1 parent 91a1224a5e
commit f8b17a79d3
3 files changed
+47 -2

No files matched your search

@@ -0,0 +1,11 @@
# 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