#!/bin/sh
#
# Just a simple man wrapper for korean man-doc
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp):
# Hye-Shik Chang <perky@FreeBSD.org> wrote this file.  As long as you retain
# this notice you can do whatever you want with this stuff. If we meet some
# day, and you think this stuff is worth it, you can buy me a beer in return.
#
# Hye-Shik Chang
# ----------------------------------------------------------------------------
#
# $Id: kman.in,v 1.2 2002/11/19 20:08:00 perky Exp $
#

KMANPATH=/usr/local/share/man/ko_KR.eucKR
GNROFF=/usr/local/bin/groff

if [ "x$*" = "x" ]; then
	echo "Usage: kman [section] keyword"
	exit 0
fi

if [ "x$2" = "x" ]; then
	SECTION="*"
	KEYWORD="$1"
else
	SECTION="$1"
	KEYWORD="$2"
fi

MANFILE=`echo $KMANPATH/man$SECTION/$KEYWORD.$SECTION.gz 2>/dev/null`
for file in $MANFILE; do
	if [ -f "$file" ]; then
		zcat $file |
		/usr/bin/tbl |
		$GNROFF -S -mtty-char -man -Tnippon |
		/usr/bin/col |
		/usr/bin/more
		exit 0
	else
		if [ "$SECTION" = "*" ]; then
			/usr/bin/man $KEYWORD
		else
			/usr/bin/man $SECTION $KEYWORD
		fi
	fi
done
