While inspecting the source code of less, I noticed that the included manpage (less.man) used terminal escape codes for showing bold text:^[[1mNAME^[[0m       less - opposite of more^[[1mSYNOPSIS^[[0m       ^[[1mless -?^[[0m       ^[[1mless --help^[[0m       ^[[1mless -V^[[0m       ^[[1mless --version^[[0m       ^[[1mless [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]^[[0mThe command used to generate is apparently nroff -man:$ head Makefile.aut # Makefile for authoring less.EMAIL = bug-less@gnu.orgHOMEPAGE = http://www.greenwoodsoftware.com/lessSHELL = /bin/shRCS = rcsNROFF = nroff -manYet, if I run nroff -man less.nro, I get the (usual) manpage output using backspaces:N^HNA^HAM^HME^HE       less - opposite of moreS^HSY^HYN^HNO^HOP^HPS^HSI^HIS^HS       l^Hle^Hes^Hss^Hs -^H-?^H?       l^Hle^Hes^Hss^Hs -^H--^H-h^Hhe^Hel^Hlp^Hp       l^Hle^Hes^Hss^Hs -^H-V^HV       l^Hle^Hes^Hss^Hs -^H--^H-v^Hve^Her^Hrs^Hsi^Hio^Hon^HnHow do I generate the first form?
How do I generate manpages using escape codes for bold, etc.?
man;less;groff;roff
The first form is a... feature of groff.  If your nroff is not a wrapper for groff, you will see only the second form.The feature is referred to in the manual page for grotty (groff driver for typewriter-like devices):By  default,  grotty  emits  SGR  escape sequences (from ISO 6429, also called ANSI color escapes) to  change text attributes (bold, italic, colors).  This makes it possible to have eight different  back-ground background  ground  and  foreground colors; additionally, bold and italic attributes can be used at the same time  (by using the BI font).In practice, it does not work well, e.g., see how the same comment (post-processing those sequences) is misrendered here:By default, grotty emits SGR escape sequences (from ISO 6429, also called ANSI color escapes) to change text attributes (bold, italic, colors). This makes it possible to have eight different M[green]backgroundM[] and m[red]foregroundm[] colors; additionally, bold and italic attributes can be used BI]at the same time] (by using the BI font). and for that reason, some developers choose not to use it (e.g., this discussion from Emacs mailing list).However, as the manual page says By default.  So, if you have groff, then it should be producing those escape sequences.Packagers may apply patches to modify programs.  A comment by @muru mentions the version in Debian (see bug reports and package page).  The package changelog says this: -- Colin Watson <cjwatson@debian.org>  Sat, 27 Jul 2002 18:41:46 +0100groff (1.18-1) unstable; urgency=low   * Disable the new ANSI colour/bold/underline escapes in nroff mode,    because most pagers either fail to cope with it or need special options    to do so. It can be re-enabled by editing /etc/groff/man.local and    /etc/groff/mdoc.local, or by setting the environment variable GROFF_SGR    to something non-empty.However, the groff source does not mention GROFF_SGR; it has only references to GROFF_NO_SGR:./NEWS:1108:  for the GROFF_NO_SGR environment variable also../NEWS:1450:o If the environment variable GROFF_NO_SGR is set, SGR output is disa..../PROBLEMS:33:  1. Set the GROFF_NO_SGR environment variable../doc/webpage.ms:1920:.  URL #GROFF_NO_SGR GROFF_NO_SGR./doc/webpagewebpage.ms:1922:. nop GROFF_NO_SGR./doc/webpagewebpage.ms:2437:.TAG GROFF_NO_SGR        ./doc/webpagewebpage.ms:2439:If the environment variable GROFF_NO_SGR is set, SGR output is ./src/devices/grotty/grotty.man:126:.B GROFF_NO_SGR./src/devices/grotty/grotty.man:394:.B GROFF_NO_SGR./src/devices/grotty/tty.cpp:864:  if (getenv(GROFF_NO_SGR))and the changelog (ChangeLog.118) gives no clue:2002-02-12  Werner LEMBERG  <wl@gnu.org>        * src/libs/libgroff/Makefile.sub (snprintf.o): Don't use        $(COMPILE.c) to not include groff's assert.h.                * src/drivers/grotty/tty.cc (main): Add GROFF_NO_SGR environment        variable.                                   * NEWS, src/drivers/grotty/grotty.man: Document it. Setting GROFF_NO_SGR will not give SGR sequences (the manpage is correct).  The Debian changelog comment refers to this chunk from /etc/groff/man.local, where Debian added a check for the GROFF_SGR variable:.  \ Debian: Disable the use of SGR (ANSI colour) escape sequences by.  \ grotty. .  if '\V[GROFF_SGR]'' \.    output x X tty: sgr 0and setting the environment variable does make it generate SGR sequences for bold, etc.