#!/bin/bash
#
# $Id$
# Author: Markus Wenzel, TU Muenchen
# License: GPL (GNU GENERAL PUBLIC LICENSE)
#
# DESCRIPTION: view Isabelle documentation
PRG=$(basename "$0")
function usage()
{
echo
echo "Usage: $PRG [DOC]"
echo
echo " View Isabelle documentation DOC, or show list of available documents."
echo
exit 1
}
function fail()
{
echo "$1" >&2
exit 2
}
## args
DOC=""
[ "$#" -ge 1 ] && { DOC="$1"; shift; }
[ "$#" -ne 0 -o "$DOC" = "-?" ] && usage
## main
if [ -z "$DOC" ]; then
ORIG_IFS="$IFS"
IFS=":"
for DIR in $ISABELLE_DOCS
do
[ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"
done
IFS="$ORIG_IFS"
else
ORIG_IFS="$IFS"
IFS=":"
for DIR in $ISABELLE_DOCS
do
[ -f "$DIR/$DOC.dvi" ] && { cd "$DIR"; IFS="$ORIG_IFS"; exec $DVI_VIEWER "$DOC.dvi"; }
done
IFS="$ORIG_IFS"
fail "Unknown Isabelle document: $DOC"
fi