forked from metamath/set.mm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathverify
executable file
·60 lines (46 loc) · 1.32 KB
/
verify
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
53
54
55
56
57
58
59
60
#!/bin/sh
# Verify mmfile $1 (default "set.mm")
set -eu
extra=''
top_date_skip=''
verify_markup=true
# NL = newline
NL="$(printf '\nX')"
NL="${NL%X}"
inner_commands='verify proof *'
while [ $# -gt 0 ] ; do
case "$1" in
--top_date_skip) shift ; top_date_skip=' /top_date_skip' ;; # Extra command
--no-verify-markup) verify_markup=false ; shift ;;
--extra) shift ; extra="$1"; shift ;; # Extra command
--*) echo "Error, unknown option $1" ; exit 1 ;;
*) break ;;
esac
done
mmfile="${1:-'set.mm'}"
if [ "$verify_markup" = true ] ; then
inner_commands="${inner_commands}${NL}verify markup *${top_date_skip}"
fi
if [ -n "$extra" ] ; then
inner_commands="${inner_commands}${NL}${extra}"
fi
# Run metamath's "verify" program. This uses a here-document to handle
# "extra" commands (since they can be blank).
run_verify () {
metamath << COMMANDS
set echo on
set scroll continuous
read ${mmfile}
${inner_commands}
quit
COMMANDS
}
# Run verify command, tee results to a separate file so we can examine it.
run_verify | tee mm$$.log
# Get status, which is false (nonzero) if an error or warning was found.
! grep -E -q '[?]Error|[?]Warning' < mm$$.log > /dev/null
result=$?
# Remove the log, or we'll have lots of useless logs
rm mm$$.log
# Return result, which is false (nonzero) if there was a problem.
exit "$result"