groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Piping man into grep - grotty sgr0 message


From: G. Branden Robinson
Subject: Re: Piping man into grep - grotty sgr0 message
Date: Tue, 18 Jul 2023 17:07:43 -0500

Hi Michael,

At 2023-07-18T17:47:35-0400, Michael J. Donovan via wrote:
> Updated to 1.23.0
> man works as before, except when you pipe its output to another command.
> 
>     man ls | grep color
>     grotty:<standard input>:(<standard input>):9: warning: unrecognized X
> command 'sgr 0' ignored
>        --color[=WHEN]

It looks like your distributor might be carrying a somewhat popular
patch, often to the "site.tmac" file, that injects an "sgr" device
control command into *roff output.

Here's an example:

https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/tools/text/groff/site.tmac

> In my .bashrc:
>     export MANROFFOPT='-c'
>     export GROFF_NO_SGR=1

These are mutually redundant; you only need one of them.  And you still
get the diagnostic message because the patch linked above pays no heed
to the "GROFF_NO_SGR" environment variable.

The "GROFF_SGR" (note the absence of "NO") patch apparently originated
with Debian 21 years ago, but its package maintainer, Colin Watson, who
handled groff (and man-db) for that distribution then and now, has
dropped it from Debian's groff 1.23.0 packages.

https://salsa.debian.org/debian/groff/-/commit/f0a34f20ff772f692255b7e32a05630c639f75a8

Colin's commit message summarizes the rationale for this decision more
succinctly than I would.

>> I turned these off for Debian in 2002 because pagers didn't cope well
>> at the time, but it's now 21 years later and things have changed; SGR
>> escape sequences resolve some ambiguity (see #963490) and are
>> required for new features such as clickable hyperlinks.

On the other hand, from Web traffic I have noticed that some people are
aggrieved because when grotty(1) uses SGR escape sequences instead of
overstriking, a somewhat popular hack to get the less(1) pager to
colorize elements of man pages is defeated.

Here is a discussion of that issue from this list earlier this month.

https://lists.gnu.org/archive/html/groff/2023-07/msg00058.html

The take-away is: drop the patch to "site.tmac" or ask your distributor
to do so.

Does this help?

Regards,
Branden

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]