#!/bin/sh

# $Id: missing_manpage_finder 71 2007-03-14 17:27:36Z branden $

# Copyright 2005 Branden Robinson
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

if [ $# -lt 1 ]; then
    set -- /bin /sbin /usr/bin /usr/sbin /usr/games
fi

NUM_EXECUTABLES=0
NUM_MANPAGES_FOUND=0
NUM_MANPAGES_MISSING=0

for DIR in "$@"; do
    for F in "$DIR"/*; do
        NUM_EXECUTABLES=$(( $NUM_EXECUTABLES + 1 ))
        if man -w "$F" >&-; then
            NUM_MANPAGES_FOUND=$(( $NUM_MANPAGES_FOUND + 1 ))
        else
            NUM_MANPAGES_MISSING=$(( $NUM_MANPAGES_MISSING + 1 ))
        fi
    done
done

printf "Of %d commands, found manpages for %d (%d missing).\n" \
    $NUM_EXECUTABLES \
    $NUM_MANPAGES_FOUND \
    $NUM_MANPAGES_MISSING

# vim:set ai et sw=4 ts=4 tw=80:
