Literal "ESC" text corrupts colorized table and --json output on iTerm2 (2.101.0)
Describe the bug
On gh 2.101.0, gh pr list (and other commands using the new styled table renderer) prints a literal ASCII text string ESC in place of some real escape bytes when run in an interactive iTerm2 session. gh pr list --json ... pretty-print output shows the same corruption via a separate colorizer path, and is not fixed by NO_COLOR=1 (which does fix the plain table view).
Reproduction steps
- Run
gh pr listdirectly in an interactive iTerm2 terminal (not piped). - Observe literal
ESC[...text mixed into the header row instead of rendering as color/style. - Run
gh pr list --json number,title,headRefName,createdAt— same corruption, unaffected byNO_COLOR=1.
Piped output (gh pr list | cat) is unaffected — gh correctly disables color when stdout is not a tty.
Evidence
Captured via script -q /tmp/gh-out.txt gh pr list (preserves pty) and inspected with xxd:
00000060: 376d 4553 431b 5b32 376d 5b30 3b32 3b34 7mESC.[27m[0;2;4
00000070: 3b33 376d 4944 2020 1b5b 376d 4553 431b ;37mID .[7mESC.Decoded: ESC[7m (real reverse-video-on) is followed by the literal text bytes E S C (0x45 0x53 0x43), then ESC[27m (real reverse-video-off), then [0;2;4;37m as literal text — missing its leading \x1b byte entirely — before the actual header text ID.
This is consistent across every styled field in the header row and in --json pretty-print output; it is not random corruption, and it does not occur on plain (non-interactive/piped) output.
Preamble also shows an OSC 11 background-color query and DSR cursor-position query before the corrupted table renders:
1b5d 3131 3b3f 1b5c 1b5b 366e 1b5b 3f31 .]11;?.\.[6n.[?1
3034 3968 1b5b 3635 3b31 481b 5b3f 3168 049h.[65;1H.[?1hIsolation performed
git log --color=alwaysrenders correctly in the same terminal session — rules out iTerm2/terminfo/locale as the cause.- Verified
TERM=xterm-256color,COLORTERM=truecolor, noGH_FORCE_TTY/NO_COLORset beforehand, no gh alias/extension/shell wrapper involved. gh config get colorreturnscould not find key "color"(key doesn't exist on this version).NO_COLOR=1 gh pr listrenders the table cleanly.NO_COLOR=1 gh pr list --json ...still shows the corrupted literal-ESCoutput — the JSON colorizer path ignoresNO_COLOR.
Related issues checked
- #10830 describes a related-but-distinct bug: on urxvt/VTE, a malformed/oversized OSC 11 response overflows termenv's fixed read buffer and leaks garbage into stdin, breaking interactive prompts. That's a buffer-truncation/stdin-leak bug. This report is different: real ESC bytes are present and well-formed elsewhere in the stream, but specific style transitions substitute a literal text string
"ESC"for an actual\x1bbyte, corrupting output rendering (not stdin) in both the table view and--jsonpretty-print. - #13335 (NO_COLOR/CLICOLOR ignored on iTerm2/macOS) is tangentially related to the
--jsonNO_COLOR gap above but doesn't describe this literal-text corruption.
Versions
$ gh --version
gh version 2.101.0 (2026-09-15)
https://github.com/cli/cli/releases/tag/v2.101.0- OS: macOS 26.7 (arm64)
- Terminal: iTerm2 3.7.3
TERM=xterm-256color,COLORTERM=truecolor,LANG=en_US.UTF-8
Workaround
NO_COLOR=1 fixes the plain table view but not --json pretty-print output.
Source: cli/cli