3007
|
1 |
#!/bin/bash
|
2332
|
2 |
#
|
|
3 |
# $Id$
|
9788
|
4 |
# Author: Markus Wenzel, TU Muenchen
|
|
5 |
# License: GPL (GNU GENERAL PUBLIC LICENSE)
|
2332
|
6 |
#
|
|
7 |
# DESCRIPTION: view Isabelle documentation
|
|
8 |
|
|
9 |
|
9788
|
10 |
PRG=$(basename "$0")
|
2332
|
11 |
|
|
12 |
function usage()
|
|
13 |
{
|
|
14 |
echo
|
|
15 |
echo "Usage: $PRG [DOC]"
|
|
16 |
echo
|
|
17 |
echo " View Isabelle documentation DOC, or show list of available documents."
|
|
18 |
echo
|
|
19 |
exit 1
|
|
20 |
}
|
|
21 |
|
|
22 |
function fail()
|
|
23 |
{
|
|
24 |
echo "$1" >&2
|
|
25 |
exit 2
|
|
26 |
}
|
|
27 |
|
|
28 |
|
|
29 |
## args
|
|
30 |
|
|
31 |
DOC=""
|
9788
|
32 |
[ "$#" -ge 1 ] && { DOC="$1"; shift; }
|
2332
|
33 |
|
9788
|
34 |
[ "$#" -ne 0 -o "$DOC" = "-?" ] && usage
|
2332
|
35 |
|
|
36 |
|
|
37 |
## main
|
|
38 |
|
|
39 |
if [ -z "$DOC" ]; then
|
9788
|
40 |
ORIG_IFS="$IFS"
|
|
41 |
IFS=":"
|
|
42 |
for DIR in $ISABELLE_DOCS
|
2332
|
43 |
do
|
9788
|
44 |
[ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"
|
2332
|
45 |
done
|
9788
|
46 |
IFS="$ORIG_IFS"
|
2332
|
47 |
else
|
9788
|
48 |
ORIG_IFS="$IFS"
|
|
49 |
IFS=":"
|
|
50 |
for DIR in $ISABELLE_DOCS
|
2332
|
51 |
do
|
9788
|
52 |
[ -f "$DIR/$DOC.dvi" ] && { cd "$DIR"; IFS="$ORIG_IFS"; exec $DVI_VIEWER "$DOC.dvi"; }
|
2332
|
53 |
done
|
9788
|
54 |
IFS="$ORIG_IFS"
|
2332
|
55 |
fail "Unknown Isabelle document: $DOC"
|
|
56 |
fi
|