Fix tput errors on unknown terminals (e.g. Ghostty)#51
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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 tputchecks with atput sgr0 &>/dev/nullprobe to detect unsupported/unknown terminals. - Install a no-op
tput()shell function whentputcan’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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
cli/lib/logging.bash(andcli/run-tests.bash) only checked whethertputwas installed, not whether it could handle the current$TERM. On terminals whose terminfo entry is missing from the system database — notablyxterm-ghosttyon stock macOS — everyinfo/warning/errorcall emittedtput: unknown terminal "xterm-ghostty"to stderr, producing output like10:35:49 tput: unknown terminal "xterm-ghostty"duringsandcat init.tput sgr0 &>/dev/nullinstead, 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