#1081·skills

`_clear` in the wizard template kills the wizard on a terminal that cannot clear

Author: TPOHHCreated Sep 14, 2026Updated Sep 14, 2026

template.sh:35 picks the ANSI fallback by the presence of tput, not by the call succeeding:

if command -v tput >/dev/null 2>&1; then tput clear; else printf '\033[2J\033[3J\033[H'; fi

tput is almost always installed, but it fails when TERM has no terminfo entry for clearing the screen:

$ TERM=dumb tput clear; echo $?
1

Under the template's own set -euo pipefail that exit code kills the wizard inside banner, before the first line of output. The user sees an empty screen and exit code 1, with no reason and no first question. Seen on TERM=dumb and inside a CI pty; a wizard generated from this template is unusable on such a terminal.

Fix: branch on the call, not on the binary.

-  if command -v tput >/dev/null 2>&1; then tput clear; else printf '\033[2J\033[3J\033[H'; fi
+  if command -v tput >/dev/null 2>&1 && tput clear 2>/dev/null; then return 0; fi
+  printf '\033[2J\033[3J\033[H'

A failure inside an if condition does not trip errexit, so this is safe under set -e in bash 3.2 as well; 2>/dev/null keeps terminfo complaints from preceding the banner.

Reproduce on a pty, not a pipe: _clear returns 0 early when stdout is not a tty, so the defect does not exist under a pipe.