Open QiBaobin opened 3 months ago
What version of man
are you using (man --version
might give a hint)?
Do you have any custom man
con figuration, like a $MANOPT
environment variable?
Traditionally man
formats its output for an actual form-feed printer, and it's up to a tool like less
(or Kakoune, or classics like ul
and colcrt
) to convert that into the formatting codes used by your terminal. It looks like your man
is emitting terminal formatting codes directly, and causing Kakoune to get confused.
2.12.1, link is here : https://github.com/NixOS/nixpkgs/blob/d3f42bd62aa840084563e3b93e4eab73cb0a0448/pkgs/tools/misc/man-db/default.nix#L18
no any related environment variable.
I tried use embed man in the mac osx, /usr/bin/man
, same behavior.
On my machine (using man-db 2.12.1 on Debian Testing), if I pipe the output of man
to a file (the same way Kakoune does), it's printed without formatting:
$ man man > /tmp/man-plain.txt
$ hexdump -C /tmp/man-plain.txt | head
00000000 4d 41 4e 28 31 29 20 20 20 20 20 20 20 20 20 20 |MAN(1) |
00000010 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
*
00000060 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 4d | M|
00000070 61 6e 75 61 6c 20 70 61 67 65 72 20 75 74 69 6c |anual pager util|
00000080 73 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 |s |
00000090 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
*
000000e0 20 20 20 20 20 20 20 20 20 4d 41 4e 28 31 29 0a | MAN(1).|
000000f0 0a 4e 41 4d 45 0a 20 20 20 20 20 20 20 6d 61 6e |.NAME. man|
...but if I force it to produce "ascii" output, it generates escape sequences like you're seeing:
$ man -Tascii man > /tmp/man2.txt
$ hexdump -C /tmp/man2.txt | head
00000000 1b 5b 34 6d 4d 41 4e 1b 5b 32 34 6d 28 31 29 20 |.[4mMAN.[24m(1) |
00000010 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000020 20 20 20 20 20 20 20 4d 61 6e 75 61 6c 20 70 61 | Manual pa|
00000030 67 65 72 20 75 74 69 6c 73 20 20 20 20 20 20 20 |ger utils |
00000040 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | |
00000050 20 1b 5b 34 6d 4d 41 4e 1b 5b 32 34 6d 28 31 29 | .[4mMAN.[24m(1)|
00000060 0a 0a 1b 5b 31 6d 4e 41 4d 45 1b 5b 30 6d 0a 20 |...[1mNAME.[0m. |
00000070 20 20 20 20 20 20 6d 61 6e 20 2d 20 61 6e 20 69 | man - an i|
00000080 6e 74 65 72 66 61 63 65 20 74 6f 20 74 68 65 20 |nterface to the |
00000090 73 79 73 74 65 6d 20 72 65 66 65 72 65 6e 63 65 |system reference|
I suspect something about your configuration is forcing it or tricking it into producing formatted output, but I have no idea what.
It seems like debian
(at least on stable releases) disables the SGR
escape sequences for TTYs in /etc/groff/man.local
.
This feature seems to be enabled by default with groff 1.23
and causes man
itself to emit escape sequences even without a pager like less
. See https://lists.gnu.org/archive/html/groff/2023-07/msg00051.html.
Setting GROFF_NO_SGR=1
seems to fix the issue. I think we should consider updating the man invocation.
It's a problem in nixpkgs
....
Question
Below content was shown when I run
man man
, it works in the shell or vim, anything did I miss?