Repository navigation
fix(tput): TERM-aware capability table, setaf/setab/cup, raw output path (#1258) - #1269
Merged
Merged
Conversation
…ath (#1258) - Answer capabilities from the TERM-named terminfo entry instead of ignoring TERM: verified byte-for-byte table for xterm/xterm-256color/ screen/screen-256color/tmux-256color/linux/vt100 (same oracle data as the rubash#884 inline arm), dumb answers the all-absent surface, and an unlisted TERM keeps the historical xterm-family fallback. - setaf/setab/cup implemented; numeric operands go through strtol(base 0) like ncurses so octal/hex spellings stay byte-equal (setaf 010 -> \e[38m, cup 010 010 -> \e[9;9H). Missing/empty TERM reports GNU's "tput: No value for $TERM and no -T specified" rc 2 and -T is honored. - Capability bytes are terminal protocol data: write them with a raw WriteFile that bypasses the i18n translate path. The first safePrint used to pay the lazy catalog read+parse once per process, which is the ~17 ms per-invocation overhead reported on catalog-installed hosts (measured: tput bold zh-CN+catalog ~0.4ms in-process after the change vs ~18ms before, spawn floor unchanged). - GNU consumes argv as a capname stream, so `tput cup 5 10 clear` emits both strings; absent capabilities stay silent rc 1. Fixes #1258 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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
tputnow resolves capabilities from theTERM-named terminfo entry instead of a hardcoded TERM-agnostic table (WinuxCmd side of the rubash#884 inline whitelist arm; same oracle data).strtol(arg, NULL, 0)like ncurses, so octal/hex spellings stay byte-equal (setaf 010→\e[38m,cup 010 010→\e[9;9H).xterm-256color/xtermanswer their respective families;dumbreports every capability absent (silent rc 1, ncurses contract); unset/empty TERM printstput: No value for $TERM and no -T specifiedand exits 2 (GNU usage error);-Toverrides$TERM. An unlisted TERM keeps the historical xterm-family answers.safePrintpays the lazycatalog()read+JSON-parse once per process whenWINUX_LANGselects an installed catalog (measured on this host: zh-CN + zh-CN catalog → +20 ms for every output-emitting command;truenever pays because it never prints). Capability bytes are terminal protocol data, not natural language, so they now go through a rawWriteFilethat bypasses translation entirely. Post-fix in-process time fortput boldis ~0.4 ms, identical totrue; the residual per-invocation wall time (~17-19 ms on this host) is process spawn + CRT/registry init shared by every command.tput cup 5 10 clearemits both), and absent capabilities stay silent rc 1.Oracle verification
matrix_gnu.txt, WSL ncurses 6.4) against this binary: 3208 rows, 0 byte mismatches — includes the strtol base-0 operand family the CR found divergent in the sibling arm (here the same libc call answers them directly, no narrowing needed since there is no fallback binary).Test plan
matrix_gnu.txtreplay: 3208/3208 byte-identicali18n companion: unixwin/winuxcmd-i18n@main (catalogs/zh-CN + VERSION 0.6.19) already pushed.
Fixes #1258
Generated with Devin