Re: 'safe' printing to the terminal

[email protected] (Gianni Ceccarelli via perl5-porters) Sun, 10 May 2026 17:14:44 +0100
Newsgroups perl.perl5.porters
Message-ID <[email protected]>
On 2026-05-10 Aristotle Pagaltzis wrote:
> The place I’d be most inclined to look would be the source of the
> `less` pager… but it’s not a pleasant codebase for finding or
> isolating that logic. :-/  (It has a toggle for whether to pass
> escape sequences through or escape them, which is stored in the
> `ctldisp` variable. You can start with that symbol and lose your mind
> from there…)

Probably easier: the "quotearg" bit of the shared GNU library

https://gitweb.git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/quotearg.h;hb=HEAD

https://gitweb.git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/quotearg.c;hb=HEAD

It's used by `ls`, `cksum`, and others that have to display filenames
to the terminal. It's *exactly* Michiel's use-case. The header file
contains a description of the various styles, and the most relevant
function is `quotearg_buffer_restyled`

-- 
	Dakkar - <Mobilis in mobile>
	GPG public key fingerprint = A071 E618 DD2C 5901 9574
	                             6FE2 40EA 9883 7519 3F88
	                    key id = 0x75193F88