All My Stupid Man Pages Are Out Of Date

I got annoyed today when I ls-ed on my Mac OS X 10.5 system and saw this:

drwxr-xr-x@ 3 root  wheel  170 Jun  7 17:35 F9D86DAF-2868-4918-948A-110BB55DAB11

Well, that’s not what got me annoyed. I tried to look up what the ‘@’ after the permissions meant in the man page and it didn’t mention it at all. I searched the web and found someone quote an excerpt of the man page that explained the ‘@’. And it was not in my man page at all! That is when I got annoyed.

Then I remembered an exchange with a commenter: earlier where it seemed like my docs were old.

So I set out to find why my man pages were out of date. After some poking around I discovered this:

$ ls -l /usr/share/man/man1/ls.1*
-r--r--r--    1 root     wheel       15708 Mar  1  2006 /usr/share/man/man1/ls.1
-r--r--r--    1 root     wheel        6220 Apr 20  2008 /usr/share/man/man1/ls.1.gz

So at some point the system installed new, nicely gzipped man pages but somehow failed to remove the old ones. And it turns out the man give the non-gzipped version precedence. Giving me old out of date documentation when I ask for it. Weak.

A quickie perl script seemed in order:

find /usr/share/man -name "*.gz" -or -print \
    | perl -ne 'chomp; print "$_n" if -f "$_.gz" && -M $_ > -M "$_.gz"' \
    | xargsn -n 10 sudo rm

where xargsn is defined in my .bashrc file as:

alias xargsn="tr '\n' '\0' | xargs -0"

Using GNU xargs you can just do xargs -d\\n which is way easier for me to remember but stupid bsd xargs doesn’t appear to have the nice -d option. Weak, but I digress.

Anyway, the script finds non-gzipped files in the system man hierarchy and, if they have an equivalent gzipped version that happens to be newer, deletes them.

I had about 4500 that I was able to delete, and now my ls and chmod man pages have up-to-date info again. Aaaahhhhh.

You might notice that I only deleted the non-gzipped version if it was older. It turns out I had about 10 man pages where the opposite was true. So I tweaked my script a little and did this:

find /usr/share/man -name "*.gz" -or -print \
    | perl -ne 'chomp; print "$_n" if -f "$_.gz" && -M $_ < -M "$_.gz"' \
    | xargsn -n 1 sudo gzip -f

This one gzips the man page and replaces the older gzipped version when they both exist and the gzipped is older.

Leave a Reply

Your email address will not be published. Required fields are marked *