#!/bin/sh

# Calculates the manpath for all installed Zeus products

if test "x$1" = x--help; then
  echo "Typical usage:"
  echo ""
  echo "  MANPATH=\`manpath\`; export MANPATH"
  echo "  MANPATH=\`manpath\` man <name>"
  echo
  exit 0
fi

# Ensure ZEUSHOME is setup to point to our installation
if [ -z "$ZEUSHOME" ]
then
    # Have a good guess, we live in $ZEUSHOME/admin/bin
    OLD_PWD=`pwd`
    cd `dirname $0`/../..
    ZEUSHOME=`pwd`
    export ZEUSHOME
    cd $OLD_PWD
fi

if [ ! -d "$ZEUSHOME/admin" ]
then
  echo 'FATAL: $ZEUSHOME is not set, or is set incorrectly'
  echo 'It should point to the Zeus installation running the adminserver'
  exit 1
fi
cd $ZEUSHOME

manpath=""
for i in *;
do
  if [ -d $i -a -h $i ];
  then
    if [ -d $i/man ];
    then
      if [ "X$manpath" != "X" ];
      then
        manpath=$manpath:
      fi
      manpath=$manpath$ZEUSHOME/$i/man
    fi
  fi
done
echo $manpath
exit 0


=head1 NAME

manpath - calculates manpath for all installed Zeus Products

=head1 SYNOPSIS

B<manpath>

=head1 DESCRIPTION

B<manpath> prints out the path required to browse all the man pages
for installed Zeus products. Typical usage with a Bourne shell would
be:

    MANPATH=`manpath`:$MANPATH; export MANPATH

=head1 NOTES

You have to use this program properly before you can easily access
this man page.

=head1 COPYRIGHT

Copyright (C) 2000-2013 Zeus Technology Limited. All rights reserved.

=cut
