| author | wenzelm | 
| Sat, 23 Apr 2011 19:22:11 +0200 | |
| changeset 42470 | cc78b0ed0fad | 
| parent 32390 | 468eff174a77 | 
| child 52427 | 9d1cc9a22177 | 
| permissions | -rwxr-xr-x | 
| 10555 | 1  | 
#!/usr/bin/env bash  | 
| 2332 | 2  | 
#  | 
| 9788 | 3  | 
# Author: Markus Wenzel, TU Muenchen  | 
| 2332 | 4  | 
#  | 
5  | 
# DESCRIPTION: view Isabelle documentation  | 
|
6  | 
||
7  | 
||
| 10511 | 8  | 
PRG="$(basename "$0")"  | 
| 2332 | 9  | 
|
10  | 
function usage()  | 
|
11  | 
{
 | 
|
12  | 
echo  | 
|
| 28650 | 13  | 
echo "Usage: isabelle $PRG [DOC]"  | 
| 2332 | 14  | 
echo  | 
15  | 
echo " View Isabelle documentation DOC, or show list of available documents."  | 
|
16  | 
echo  | 
|
17  | 
exit 1  | 
|
18  | 
}  | 
|
19  | 
||
20  | 
function fail()  | 
|
21  | 
{
 | 
|
22  | 
echo "$1" >&2  | 
|
23  | 
exit 2  | 
|
24  | 
}  | 
|
25  | 
||
26  | 
||
27  | 
## args  | 
|
28  | 
||
29  | 
DOC=""  | 
|
| 9788 | 30  | 
[ "$#" -ge 1 ] && { DOC="$1"; shift; }
 | 
| 2332 | 31  | 
|
| 9788 | 32  | 
[ "$#" -ne 0 -o "$DOC" = "-?" ] && usage  | 
| 2332 | 33  | 
|
34  | 
||
35  | 
## main  | 
|
36  | 
||
| 
32390
 
468eff174a77
function splitarray: splightly more abstract version that accomodates older bashes;
 
wenzelm 
parents: 
32322 
diff
changeset
 | 
37  | 
splitarray ":" "$ISABELLE_DOCS"; DOCS=("${SPLITARRAY[@]}")
 | 
| 
32322
 
45cb4a86eca2
change IFS only locally -- thanks to bash arrays;
 
wenzelm 
parents: 
29143 
diff
changeset
 | 
38  | 
|
| 2332 | 39  | 
if [ -z "$DOC" ]; then  | 
| 
32322
 
45cb4a86eca2
change IFS only locally -- thanks to bash arrays;
 
wenzelm 
parents: 
29143 
diff
changeset
 | 
40  | 
  for DIR in "${DOCS[@]}"
 | 
| 2332 | 41  | 
do  | 
| 15703 | 42  | 
[ -d "$DIR" ] || fail "Bad document directory: $DIR"  | 
| 9788 | 43  | 
[ -f "$DIR/Contents" ] && grep -v "^>>" "$DIR/Contents"  | 
| 2332 | 44  | 
done  | 
45  | 
else  | 
|
| 
32322
 
45cb4a86eca2
change IFS only locally -- thanks to bash arrays;
 
wenzelm 
parents: 
29143 
diff
changeset
 | 
46  | 
  for DIR in "${DOCS[@]}"
 | 
| 2332 | 47  | 
do  | 
| 15703 | 48  | 
[ -d "$DIR" ] || fail "Bad document directory: $DIR"  | 
49  | 
for FMT in "$ISABELLE_DOC_FORMAT" dvi  | 
|
50  | 
do  | 
|
| 28500 | 51  | 
      [ -f "$DIR/$DOC.$FMT" ] && { cd "$DIR"; exec "$ISABELLE_TOOL" display "$DOC.$FMT"; }
 | 
| 15703 | 52  | 
done  | 
| 2332 | 53  | 
done  | 
54  | 
fail "Unknown Isabelle document: $DOC"  | 
|
55  | 
fi  | 
|
| 15717 | 56  |