#! /bin/ash
#########################################
# mu-man - rustic man-pages for muLinux 
# by M. Andreoli (1999) 
##########################################

#set -x

usage()
{
cat <<END
mu-man : rustic man-pages (by M. Andreoli)

Usage:
	man [-h|-l] man-page

END
}

print_manual()
{
found=
for path in $MANPATH
do

if [ -r $path/$1 ] ; then
	found=yes
	cd $path
	less -t "$1 manual page" -b "-- q quit --" $1
fi
done

if [ -z "$found" ] ; then
	echo "No manual entry for $1: press man -l"
fi

}


# man paths

MANPATH=

if [ -r /etc/man.conf ]; then
	for p in `cat /etc/man.conf`
	do
	[ -d $p ] && MANPATH="$MANPATH $p"
	done

else
	MANPATH="/usr/man /usr/X11R6/man /gcc/usr/man"
fi


# Main

case "Z$1Z" in
Z-hZ)
	 usage 
	;;
ZZ|Z-lZ)
	echo -e $BRIGHT
	echo "Available man-pages:"
	echo -e $NORMAL
	
	/bin/ls -m  $MANPATH

	echo
	;;
*)
	print_manual $1
esac

# End
