58610
|
1 |
#!/usr/bin/env bash
|
|
2 |
#
|
|
3 |
# Author: Makarius
|
|
4 |
#
|
|
5 |
# DESCRIPTION: update theory syntax to use cartouches
|
|
6 |
|
|
7 |
|
|
8 |
## diagnostics
|
|
9 |
|
|
10 |
PRG="$(basename "$0")"
|
|
11 |
|
|
12 |
function usage()
|
|
13 |
{
|
|
14 |
echo
|
|
15 |
echo "Usage: isabelle $PRG [FILES|DIRS...]"
|
|
16 |
echo
|
61492
|
17 |
echo " Options are:"
|
61579
|
18 |
echo " -c replace comment marker \"--\" by symbol \"\\<comment>\""
|
61492
|
19 |
echo " -t replace @{text} antiquotations within text tokens"
|
|
20 |
echo
|
58610
|
21 |
echo " Recursively find .thy files and update theory syntax to use cartouches"
|
|
22 |
echo " instead of old-style {* verbatim *} or \`alt_string\` tokens."
|
|
23 |
echo
|
|
24 |
echo " Old versions of files are preserved by appending \"~~\"."
|
|
25 |
echo
|
|
26 |
exit 1
|
|
27 |
}
|
|
28 |
|
|
29 |
|
|
30 |
## process command line
|
|
31 |
|
61492
|
32 |
# options
|
|
33 |
|
61579
|
34 |
COMMENT="false"
|
61492
|
35 |
TEXT="false"
|
|
36 |
|
61579
|
37 |
while getopts "ct" OPT
|
61492
|
38 |
do
|
|
39 |
case "$OPT" in
|
61579
|
40 |
c)
|
|
41 |
COMMENT="true"
|
|
42 |
;;
|
61492
|
43 |
t)
|
|
44 |
TEXT="true"
|
|
45 |
;;
|
|
46 |
\?)
|
|
47 |
usage
|
|
48 |
;;
|
|
49 |
esac
|
|
50 |
done
|
|
51 |
|
|
52 |
shift $(($OPTIND - 1))
|
|
53 |
|
|
54 |
|
|
55 |
# args
|
|
56 |
|
58610
|
57 |
[ "$#" -eq 0 -o "$1" = "-?" ] && usage
|
|
58 |
|
|
59 |
SPECS="$@"; shift "$#"
|
|
60 |
|
|
61 |
|
|
62 |
## main
|
|
63 |
|
|
64 |
find $SPECS -name \*.thy -print0 | \
|
61579
|
65 |
xargs -0 "$ISABELLE_TOOL" java isabelle.Update_Cartouches "$COMMENT" "$TEXT"
|