Skip to content

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

Description

@TPOHH

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions