Skip to content

Fix tput errors on unknown terminals (e.g. Ghostty)#51

Merged
adamw merged 1 commit intomasterfrom
fix/tput-unknown-terminal
Apr 18, 2026
Merged

Fix tput errors on unknown terminals (e.g. Ghostty)#51
adamw merged 1 commit intomasterfrom
fix/tput-unknown-terminal

Conversation

@adamw
Copy link
Copy Markdown
Member

@adamw adamw commented Apr 18, 2026

Summary

  • cli/lib/logging.bash (and cli/run-tests.bash) only checked whether tput was installed, not whether it could handle the current $TERM. On terminals whose terminfo entry is missing from the system database — notably xterm-ghostty on stock macOS — every info/warning/error call emitted tput: unknown terminal "xterm-ghostty" to stderr, producing output like 10:35:49 tput: unknown terminal "xterm-ghostty" during sandcat init.
  • Probe with tput sgr0 &>/dev/null instead, so the no-op stub is installed whenever tput cannot handle the current terminal.

Test plan

  • TERM=xterm-ghostty bash -c 'source cli/lib/logging.bash && echo test | info' — no stderr noise, log line is plain.
  • TERM=xterm-256color bash -c 'source cli/lib/logging.bash && echo test | info' — color escapes still present.

🤖 Generated with Claude Code

The existing guard only checked whether `tput` was installed, so on
terminals whose terminfo entry is missing from the system database
(notably `xterm-ghostty` on stock macOS), every call emitted
`tput: unknown terminal "xterm-ghostty"` to stderr. Probe with
`tput sgr0` so the stub kicks in whenever tput cannot handle the
current `$TERM`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 18, 2026 20:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the CLI’s use of tput so it doesn’t emit stderr noise on terminals whose $TERM has no terminfo entry (e.g., xterm-ghostty on stock macOS), by probing tput usability rather than mere presence.

Changes:

  • Replace command -v tput checks with a tput sgr0 &>/dev/null probe to detect unsupported/unknown terminals.
  • Install a no-op tput() shell function when tput can’t operate for the current terminal, preventing repeated stderr output.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
cli/run-tests.bash Uses tput sgr0 probe and stubs tput when unusable to avoid noisy test output.
cli/lib/logging.bash Uses tput sgr0 probe and stubs tput when unusable to prevent log helpers from emitting terminfo errors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@adamw adamw merged commit 46a66ce into master Apr 18, 2026
9 checks passed
@adamw adamw deleted the fix/tput-unknown-terminal branch April 18, 2026 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants