58872
|
1 |
#!/usr/bin/env bash
|
|
2 |
#
|
|
3 |
# Author: Makarius
|
|
4 |
#
|
|
5 |
# DESCRIPTION: replace obsolete theory header command
|
|
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
|
|
17 |
echo " Options are:"
|
|
18 |
echo " -s COMMAND alternative heading command (default 'section')"
|
|
19 |
echo
|
|
20 |
echo " Recursively find .thy files and replace obsolete theory header commands"
|
|
21 |
echo " by 'section' (default), or 'chapter', 'subsection', 'subsubsection'."
|
|
22 |
echo
|
|
23 |
echo " Old versions of files are preserved by appending \"~~\"."
|
|
24 |
echo
|
|
25 |
exit 1
|
|
26 |
}
|
|
27 |
|
|
28 |
|
|
29 |
## process command line
|
|
30 |
|
|
31 |
#options
|
|
32 |
|
|
33 |
SECTION="section"
|
|
34 |
|
|
35 |
while getopts "s:" OPT
|
|
36 |
do
|
|
37 |
case "$OPT" in
|
|
38 |
s)
|
|
39 |
SECTION="$OPTARG"
|
|
40 |
;;
|
|
41 |
\?)
|
|
42 |
usage
|
|
43 |
;;
|
|
44 |
esac
|
|
45 |
done
|
|
46 |
|
|
47 |
shift $(($OPTIND - 1))
|
|
48 |
|
|
49 |
|
|
50 |
# args
|
|
51 |
|
|
52 |
[ "$#" -eq 0 -o "$1" = "-?" ] && usage
|
|
53 |
|
|
54 |
SPECS="$@"; shift "$#"
|
|
55 |
|
|
56 |
|
|
57 |
## main
|
|
58 |
|
|
59 |
find $SPECS -name \*.thy -print0 | \
|
|
60 |
xargs -0 "$ISABELLE_TOOL" java isabelle.Update_Header "$SECTION"
|