On Wed, Mar 04, 2026 at 08:34:53PM +0000, Stephane Chazelas wrote:
> AFAICT, the output of "infocmp -L" should be processable by
> "tic" to reproduce the terminfo entry in that tic seems to
> understand those long capability names, and it works in practice
> for some terminfo entries but only those where none of those
> capabilities contain backslash characters as with "-L" it seems
> those backslashes are not escaped as \\.
>
> Example:
>
> OK for vt100:
>
> $ ./infocmp -x1 vt100 | grep -F '\\'
> $ ./infocmp -x1 vt100 | tic -cx -
> $
>
> But for xterm-256color:
>
> $ ./infocmp -V
> ncurses 6.6.20260301
>
> $ ./infocmp -x1 xterm-256color| grep -F '\\'
>
> initc=\E]4;%p1%d;rgb:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
> rv=\E\\[>41;[1-6][0-9][0-9];0c,
> xr=\EP>\\|XTerm\\(([1-9][0-9]+)\\)\E\\\\,
>
> $ ./infocmp -Lx1 xterm-256color| grep -F '\\'
> xr=\EP>\|XTerm\(([1-9][0-9]+)\)\E\\,
>
> $ ./infocmp -x1 xterm-256color| tic -cx -
>
> $ ./infocmp -Lx1 xterm-256color| tic -cx -
> "<stdin>", line 295, col 15, terminal 'xterm-256color': Illegal character '['
> in \ sequence
> "<stdin>", line 298, col 24, terminal 'xterm-256color': Illegal character '('
> in \ sequence
> "<stdin>", line 298, col 39, terminal 'xterm-256color': Illegal character ')'
> in \ sequence
>
> Here, we get an error, but it could also cause corruption like
> when the output has "foo=\,bar=/," instead of "foo=\\,bar/," as
> tic would interpret it as a "foo" capability with ",bar=/" as
> value.
>
> I came across the issue when trying to compile the terminfo
> entry shown at
> https://unix.stackexchange.com/questions/804811/less-doesnt-let-me-type-after-using-to-search
> where I got a bogus result because of some \, in there.
>
> The "comparison" output (as in infocmp term1 term2) also seems
> to be affected.
>
> While it's not one that is intended to be processed by tic, not
> doing that escaping produces potentially ambiguous output.
>
> For example, if you see \\E you don't know whether it's two
> backslashes and a E or a backslash and ESC.in the code, it should have compared against both F_TERMINFO and F_VARIABLE. thanks (fix will be in weekend's patch) -- Thomas E. Dickey <[email protected]> https://invisible-island.net
signature.asc
Description: PGP signature
