LEXGROG(1)

๐Ÿ“ฆ
version 2.13.1 ยท 6 versions
, in alpine 3.24, arch rolling, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, ubuntu questing, ubuntu resolute, ubuntu stonking

๐ŸŽ€ LEXGROG(1) ยท Manual pager utils ๐ŸŽ€

โœจ NAME โœจ

okay so lexgrog is basically the traditional "groff guess" utility rewritten in lex ๐Ÿ’… it's giving parse-the-header-info-in-man-pages energy ๐Ÿฆ‹

๐ŸŒธ SYNOPSIS ๐ŸŒธ

lexgrog [-m|-c] [-dfw?V] [-E encoding] file ...

๐Ÿ’– DESCRIPTION ๐Ÿ’–

okay bestie, so lexgrog is an implementation of the classic groff guess utility, but written in lex โœจ it reads whatever files you hand it on the command line, and it treats each one as either a man page source file or a preformatted "cat" page ๐Ÿ“„ then it spits out their name and description (the stuff apropos and whatis use), the list of preprocessing filters the man page needs before it goes to nroff or troff, or both. literally so useful ๐Ÿ˜ญ

if the input is badly formatted, lexgrog will print "parse failed" ๐Ÿ’€ this is lowkey great for external programs that want to check whether man pages are correct ๐Ÿซถ if one of your input files is -, it reads from standard input instead ๐Ÿงš and if any input file is compressed, no worries, it gets decompressed automatically and read for you โœจ

๐Ÿ”ฅ OPTIONS ๐Ÿ”ฅ

  • -d, --debug โ€” prints debugging info, for when you need to see the tea โ˜•
  • -m, --man โ€” parses input as man page source files ๐Ÿ“œ this is the default if you don't give --man or --cat
  • -c, --cat โ€” parses input as preformatted man pages ("cat pages") ๐ŸŒˆ you can't give --man and --cat together, bestie, that's a no-go ๐Ÿ™…โ€โ™€๏ธ
  • -w, --whatis โ€” shows the name and description from the man page header, the stuff apropos and whatis use ๐Ÿ’… this is the default if you don't give --whatis or --filters
  • -f, --filters โ€” shows the list of filters needed to preprocess the man page before you format it with nroff or troff ๐Ÿฆ‹
  • -E encoding, --encoding encoding โ€” overrides the guessed character set for the page and uses encoding instead ๐ŸŒ
  • -?, --help โ€” prints a help message and exits ๐ŸŽ€
  • --usage โ€” prints a short usage message and exits ๐Ÿ’Œ
  • -V, --version โ€” shows version info ๐Ÿงš

๐Ÿšช EXIT STATUS ๐Ÿšช

  • 0 โ€” everything went slay, program ran successfully โœจ
  • 1 โ€” usage error, you fumbled the command ๐Ÿ™ˆ
  • 2 โ€” lexgrog couldn't parse one or more of the input files ๐Ÿ’€

๐Ÿ“ EXAMPLES ๐Ÿ“

$ lexgrog man.1
man.1: "man - an interface to the system reference manuals"
$ lexgrog -fw man.1
man.1 (t): "man - an interface to the system reference manuals"
$ lexgrog -c whatis.cat1
whatis.cat1: "whatis - display manual page descriptions"
$ lexgrog broken.1
broken.1: parse failed

๐Ÿง  WHATIS PARSING ๐Ÿง 

okay so mandb (which uses the exact same code as lexgrog) parses the NAME section at the top of each manual page ๐Ÿ“– it's looking for the names and descriptions of the features documented in there. the parser is super tolerant, because it has to cope with a bunch of different forms that people have used over the years ๐Ÿซถ but it can still sometimes fail to pull out the info it needs ๐Ÿ˜ญ

when you're using the traditional man macro set, a correct NAME section looks something like this:

.SH NAME
foo \- program to do something

some manual pagers need the \- to be exactly as shown ๐Ÿ™ˆ mandb is more chill about it, but for compatibility with other systems, it's still a good idea to keep the backslash ๐Ÿ’…

on the left-hand side, you can have several names separated by commas โœจ names with whitespace in them get ignored, to avoid pathological behaviour on certain ill-formed NAME sections ๐Ÿ’€ the text on the right-hand side is free-form and can be spread over multiple lines ๐ŸŒธ if several features with different descriptions are documented in the same manual page, you'd use this form:

.SH NAME
foo, bar \- programs to do something
.br
baz \- program to do nothing

(a macro that starts a new paragraph, like .PP, can be used instead of the break macro .br ๐Ÿงš)

when you're using the BSD-derived mdoc macro set, a correct NAME section looks something like this:

.Sh NAME
.Nm foo
.Nd program to do something

there are a few common reasons why whatis parsing fails ๐Ÿ˜ญ sometimes authors swap .SH NAME for .SH MYPROGRAM, so mandb can't find the section it needs to grab info from ๐Ÿ’€ other times authors include a NAME section but put free-form text in there instead of name \- description ๐Ÿ™ˆ anyway, any syntax that resembles the above should be accepted ๐Ÿ’–

๐Ÿ”— SEE ALSO ๐Ÿ”—

apropos(1), man(1), whatis(1), mandb(8) ๐Ÿฆ‹

๐Ÿ“ NOTES ๐Ÿ“

lexgrog tries to parse files containing .so requests, but it can only do that correctly if the files are properly installed in a manual page hierarchy ๐Ÿ™ˆ

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

the code lexgrog uses to scan man pages was written by:

  • Wilf. (G.Wilford@ee.surrey.ac.uk) ๐ŸŒˆ
  • Fabrizio Polacco (fpolacco@debian.org) ๐ŸŒˆ
  • Colin Watson (cjwatson@debian.org) ๐ŸŒˆ

Colin Watson wrote the current command-line front-end, as well as this man page ๐Ÿซถ

๐Ÿ› BUGS ๐Ÿ›

report them here, bestie ๐Ÿ™ˆ


and that's the tea โ˜• version 2.13.1, dated 2025-05-02, LEXGROG(1) ๐Ÿ’œ you're literally ready now bestie โœจ๐Ÿซถ

๐Ÿ“ฆ where this page comes from