forked from metamath/set.mm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregen-from-raw
executable file
·52 lines (45 loc) · 1.81 KB
/
regen-from-raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
# regen-from-raw - regenerate files from .raw parts
# $1 = Markup options (default /HTML)
# $2 = Suffix of resulting file (default .html)
# Just run this program without arguments to regen the HTML from raw files
if [ "$1" = '--force' ]; then
force=true
shift
else
force=false
fi
markup_options="${1:-"/ALT_HTML"} /SYMBOLS /LABELS"
suffix="${2:-".html"}"
# This is a list of the .raw.html files (omitting their suffix)
# that use set.mm conventions to generate non-raw versions (most of them)
setmm_raw='mmcomplex mmnatded mmset mmdeduction mmzfcnd mmfrege'
# Echo the metamath commands necessary to
# generate files from .raw files listed in $2 using db conventions of $1
generate_files_using_convention() {
convention_database="$1"
files_to_regen="$2"
echo "read $1"
echo 'set scroll continuous'
# Since $files_to_regen is a space-separated list we must NOT quote it here:
for file in $files_to_regen; do
raw_file="${file}.raw.html"
generated_file="${file}${suffix}"
# Regenerate file only if it's forced or outdated.
# The "-f" is because dash and bash's "-ot" behavior differs
# if the first file does not exist.
if [ "$force" = 'true' ] || ! [ -f "$generated_file" ] || \
[ "$generated_file" -ot "$raw_file" ] || \
[ "$generated_file" -ot "$convention_database" ] ; then
echo "markup \"${raw_file}\" \"${generated_file}\" ${markup_options}"
fi
done
echo quit
}
generate_files_using_convention 'set.mm' "$setmm_raw" | metamath | tee ,errs
generate_files_using_convention 'iset.mm' 'mmil' | metamath | tee -a ,errs
generate_files_using_convention 'nf.mm' 'mmnf' | metamath | tee -a ,errs
# Return nonzero error code if "Warning" or "Error" found in the output.
echo
echo 'RECAP: The following warnings and errors were found:'
! grep -E '^\?(Warning|Error): ' ,errs