function splitarray: splightly more abstract version that accomodates older bashes;
#!/usr/bin/env bash
#
# Author: Markus Wenzel, TU Muenchen
#
# DESCRIPTION: view Isabelle documentation
PRG="$(basename "$0")"
function usage()
{
echo
echo "Usage: isabelle $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
splitarray ":" "$ISABELLE_DOCS"; DOCS=("${SPLITARRAY[@]}")
if [ -z "$DOC" ]; then
for DIR in "${DOCS[@]}"
do
[ -d "$DIR" ] || fail "Bad document directory: $DIR"
[ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"
done
else
for DIR in "${DOCS[@]}"
do
[ -d "$DIR" ] || fail "Bad document directory: $DIR"
for FMT in "$ISABELLE_DOC_FORMAT" dvi
do
[ -f "$DIR/$DOC.$FMT" ] && { cd "$DIR"; exec "$ISABELLE_TOOL" display "$DOC.$FMT"; }
done
done
fail "Unknown Isabelle document: $DOC"
fi