Integrating less's Case-Insensitive Search with POSIX ERE Patterns in ANSI-Capable Terminals
0 reputation · 06 Jun 2022, 19:54 UTC
When viewing colorized output in less with a capable TERM setting, the pager forwards ANSI escape sequences to the terminal. Enabling case-insensitive search with the -i or -I options changes how subsequent / patterns match, but the boundary between the POSIX ERE pattern engine and terminal escape sequence pass-through leaves several interoperability details unresolved.
The core uncertainty is whether case-insensitive matching applies to the raw buffer content before escape sequences are processed for display, or to the rendered text after terminal control codes are stripped. This distinction affects how patterns with anchors, character ranges, or negated classes behave when the underlying bytes include embedded ANSI color codes.
Does the -i flag alter pattern compilation within the POSIX ERE engine, or only the final comparison step? How do character ranges and negated classes behave under case-insensitive matching when the buffer contains ANSI escape sequences? Is the search behavior consistent when TERM is set to a basic terminal versus a 256-color terminal that enables escape sequence pass-through?