forked from metamath/set.mm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlist-theorems
executable file
·38 lines (33 loc) · 1.19 KB
/
list-theorems
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
#!/bin/sh
# Creates a file which lists all the theorems ($p-statements) of the
# mmfile argument. Each line is a label with two spaces in front.
# First parameter is the mmfile (default set.mm).
# Second parameter is the output file (default 1.tmp).
# Third parameter is the first theorem to list (default first theorem of mmfile).
# Fourth parameter is the last theorem to list (default last theorem of mmfile).
# This can be a useful step to take before using scripts/min.cmd.
mmfile="${1:-set.mm}"
output="${2:-1.tmp}"
metamath "read \"${mmfile}\"" \
'set scroll continuous' \
'open log 0.tmp' \
'show labels * /linear' \
'close log' \
quit > /dev/null
grep -E ' \$p' < 0.tmp | \
sed -E -e 's/ \$p//' -e 's/^[0-9]+ / /' > "${output}"
if [ $# -gt 2 ]; then
# GNU and BSD sed handle -i differently
if sed --version > /dev/null 2>&1; then
sedflags='-i -n'
else
sedflags='-i "" -n'
fi
if [ $# -gt 3 -a -n "$3" -a -n "$4" ]; then
sed ${sedflags} "/^ $3\$/,/^ $4\$/p" "${output}"
elif [ -n "$3" ]; then
sed ${sedflags} "/^ $3\$/,\$p" "${output}"
elif [ $# -gt 3 -a -n "$4" ]; then
sed ${sedflags} "1,/^ $4\$/p" "${output}"
fi
fi