text: Running catman makes man display junk data
  Bug Description
  After running "sudo catman" to update the man page cache, the display of some man pages will be completely corrupted. Deleting the corresponding entries in /var/cache/
  I can reproduce this problem with man-db 2.5.7-3, but not with previous 2.5.6-2. I feel that it can be related to the following upstream change in 2.5.7-1:
  > - Always save cat pages in UTF-8 (closes: #446741).
  I see the following pipe being run:
  /usr/bin/zsoelim | /usr/lib/
  This is very wrong because it tries to convert gzip-compressed data from ASCII to UTF-8! Oh noes!
  == Regression details ==
  Discovered in version: 2.5.7-2 (lucid), 2.5.7-3 (maverick)
  Last known good version: 2.5.6-2 (karmic)
  == SRU details ==
  Impact: Preformatted manual pages ("cat pages") may be corrupted by running iconv after compression rather than before. This is a regression introduced upstream in man-db 2.5.7.
  Patch: Fixed upstream in http://
  TEST CASE: Run 'sudo catman 1', then make sure you're using an 80-column terminal window (so that cat pages are used) and run 'LC_ALL=C man a2p'. The broken version will show binary garbage. To clear out cat pages to test the working version, run 'sudo rm /var/cache/
  Regression potential: None seems likely, and the test case should be sufficient to catch misbuilds and the like.
  ---
  Original question by Thinboy00:
  Some man pages are appearing corrupt (i.e. if I type man foo at the terminal, I get a bunch of caret escaped characters and a few ascii characters). It looks as if man is reading the compressed data in /usr/share/man instead of uncompressing it first. I will soon attach a screenshot of the problem. The really confusing part, though, is that some man pages consistently appear corrupt and the others consistently appear correctly. I've tried the following, to no avail:
  mandb
  mandb -t
  mandb -c
  catman
  And yes, I did remember to use sudo on those. mandb -t said "whatis parse for /usr/share/
  zcat /usr/man/
  and it gave unformatted but readable output, even though man nethack doesn't work. I tried the same trick with slashem, which does work correctly for man, and the zcat trick worked too. I'm surprised their man pages behave differently since the pages themselves are practically identical.
  Is my copy of man broken?
  Could you please add the -d option to man and post the *full* output, so that I can trace through what's happening?
  BTW, the locale difference is interesting, but any fix based on tweaking it is likely to be incorrect. I'd rather find the underlying cause.
  Ah, never mind, I just managed to reproduce it myself ...
  Fixed upstream. I intend to backport this to Debian and Ubuntu.
  Tue Aug 17 14:29:53 BST 2010 Colin Watson <email address hidden>
  * src/man.c (display_catman): Add iconv to format_cmd before adding
  a compressor.
  * NEWS: Document this.
  This bug was fixed in the package man-db - 2.5.7-4
  ---------------
  man-db (2.5.7-4) unstable;> Tue, 17 Aug 2010 15:02:31 +0100
  Is this going to be put into Lucid?
  As a workaround, you can do something like: rm -f /var/cache/
  Yes, I ought to. Milestoning for 10.04.2 so I don't forget.
  Accepted man-db into lucid-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https:/
  SRU verification for Lucid:
  I have reproduced the problem with man-db 2.5.7-2 in lucid and have verified that the version of man-db 2.5.7-2ubuntu1 in -proposed fixes the issue.
  Marking as verification-done
  This bug was fixed in the package man-db - 2.5.7-2ubuntu1
  ---------------
  man-db (2.5.7-2ubuntu1) lucid-proposed;> Thu, 30 Sep 2010 13:55:29 +0100
  If I run `sudo man -L fr_CA.utf8 -caM /usr/share/man 6 nethack' from the command line, no cache file is created and so the bug does not happen. If I create a small script that runs the same command, but clears the environment, I get a junk man page. Here is a such a script:
  #!/usr/bin/python
  "/usr/bin/ man", ["man", "-L", "fr_CA.utf8", "-caM", "/usr/share/man", "6", "nethack"], {})
  import os
  os.execve(
  If I restore the environment variable about the locale, a cat file is created, but I do not get the bug:
  #!/usr/bin/python
  "/usr/bin/ man", ["man", "-L", "fr_CA.utf8", "-caM", "/usr/share/man", "6", "nethack"], {'LANG': 'fr_CA.utf8'})
  import os
  os.execve(
  So a possible solution would be for catman to add a LANG environment variable to the execve call to man. I don't know enough about the usage cases of catman; is the locale supposed to be valid? Is it good enough to be used for system-wide purposes? Otherwise, should catman fake an utf-8 locale?