From f8b17a79d31b5323dc6be986fb27f4cdf88192d9 Mon Sep 17 00:00:00 2001 From: bcherb2 Date: Wed, 18 Nov 2026 02:13:00 -0500 Subject: [PATCH] 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). --- .../31-confirm-asks-stdin-not-the-tty.mut | 11 +++++++ .tests/test.sh | 30 +++++++++++++++++++ dot_local/bin/executable_dotup | 8 +++-- 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 .tests/mutations/31-confirm-asks-stdin-not-the-tty.mut diff --git a/.tests/mutations/31-confirm-asks-stdin-not-the-tty.mut b/.tests/mutations/31-confirm-asks-stdin-not-the-tty.mut new file mode 100644 index 0000000..c5e75ed --- /dev/null +++ b/.tests/mutations/31-confirm-asks-stdin-not-the-tty.mut @@ -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 +<</dev/null || return 0 + printf '\n install? [y/N] ' >&2 +<<&2 +<</dev/null; then + ttyrun() { # ttyrun