 
#!/bin/sh
#
#
# fixdupman - fix problem of new foo.1 and old foo.1.gz
#
# Some explanation: Man pages can take up a fair bit of room, so
# gzipping them makes sense where possible. `man' copes with this, so,
# no problem. But when you come to install a new version of a program,
# it installs an uncompressed man page. This clearly wastes space, and
# worse, the .1.gz is used in preference to the .1 - so you never see
# the new man page! :-(
#
# So, this script fixes this by gzipping newer uncompressed man pages
# over existing (old) compressed ones. Usage is `fixdupman mandir' where
# mandir is the base of a man tree with man1, man2, etc. The canonical
# examples are /usr/man, /usr/local/man, and perhaps /usr/X11R6/man.
# There's no default, so you have to specify a dir.

if [ ! -d "$1" ]; then
  echo 'usage: fixdupman mandir		(e.g. /usr/man)'
  exit 1
fi

# for all files, see if there's a file.gz.

for i in `find $1 -print`; do
  # if file.gz exists and file is newer than file.gz...
  if [ -f ${i}.gz -a $i -nt ${i}.gz ]; then
    # ...then gzip new one, overwriting old.
    gzip -fv $i
  fi
done
