Repository navigation
fix(tput): numeric capabilities (colors/pairs/cols/lines) + ncurses-6.4 error contract (#1460) - #1461
Merged
Merged
Conversation
#1460) Root cause: nvm.sh:99 runs `tput -T "$TERM" colors` on every source; the WinuxCmd tput had no numeric capability family, so every nvm ls/alias printed 1-6 lines of `tput: unknown capability 'colors'` noise under both rubash and niubash. Implemented against the WSL GNU oracle (Ubuntu 24.04, ncurses 6.4), byte-for-byte on both streams (tput -T {8 terms} x {colors,pairs,cols, lines} + setaf/setab/cup/string/error matrix, script-file probe): - Numeric capabilities colors/pairs/cols/lines: value + "\n", exit 0; an absent capability prints "-1" and still exits 0 (vt100 colors, linux cols/lines, dumb lines). cols/lines come from GetConsoleScreenBufferInfo when stdout is a real console, else the terminfo constants (80/24), matching ncurses' ioctl-then-terminfo fallback. - Parameterized capabilities (setaf/setab/cup): missing operand entirely prints the raw terminfo template (rc 0); a non-numeric operand formats with 0 and the argv continues as the next capname. Raw templates carried byte-equal to the oracle. - Unknown capname: ncurses wording `tput: unknown terminfo capability 'X'` and exit 4 (was rc 1 with different wording). - No capname: usage on stderr, exit 2 (was rc 1 one-liner). Tests: 28/28 tput.* green (8 new cases for the #1460 family); two stale tests updated to the oracle (`tput lines` on xterm succeeds in GNU since lines is a numeric capability, so the #1166 stdin arm now uses an unknown capname; empty-argv and unknown-capname expectations moved to the attested rc 2 / rc 4). nvm replay with the rebuilt binary: `source nvm.sh; nvm alias; nvm ls` under rubash is now clean (zero tput noise), exit 0. Fixes #1460.
This was referenced Oct 31, 2026
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.
Closes #1460. Root cause: nvm.sh:99 runs
tput -T "$TERM" colorson every source, so every nvm ls/alias under rubash/niubash printed 1–6 lines oftput: unknown capability 'colors'noise.Implemented against the WSL GNU oracle (Ubuntu 24.04, ncurses 6.4), verified byte-for-byte on both stdout and stderr across the matrix
{xterm, xterm-256color, screen, screen-256color, tmux-256color, linux, vt100, dumb} × {colors, pairs, cols, lines}plus setaf/setab/cup/string/error paths (script-file probe, nowsl -cquoting):colors/pairs/cols/lines: value + newline, exit 0; an absent capability prints-1and still exits 0.cols/linesuseGetConsoleScreenBufferInfowhen stdout is a real console, else the terminfo constants — matching ncurses' ioctl-then-terminfo fallback.setaf/setab/cup): missing operand → raw terminfo template (rc 0); non-numeric operand → format with 0 and continue the argv loop; raw templates byte-equal to oracle.tput: unknown terminfo capability 'X', exit 4 (was rc 1, different wording).Tests:
tput.*28/28 green (8 new #1460 cases); two stale tests re-pinned to the oracle (tput lineson xterm now succeeds in GNU — numeric capability — so the #1166 stdin arm moved to an unknown capname).nvm replay after rebuild:
source nvm.sh; nvm alias; nvm lsunder rubash is clean, exit 0.