-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisable-qed.sh
executable file
·50 lines (40 loc) · 996 Bytes
/
disable-qed.sh
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
#!/usr/bin/env bash
#
# Toggle between Qed and Admitted in source code.
# To be safer than Admitted, we actually add some extra commands that ensure
# there are no remaining goals.
# Borrowed from https://github.com/mit-pdos/perennial/blob/master/etc/disable-qed.sh
SED=sed
if command -v gsed >/dev/null ; then
SED=gsed
fi
inplace_edit() {
$SED -r -i~ "$@"
}
forward_repl() {
local search='([[:space:]]*)(Time )?Qed\.'
local repl="\1Unshelve. Fail idtac. \2Admitted."
inplace_edit "s/^${search}$/${repl}/" "$@"
}
backward_repl() {
local search="([[:space:]]*)"
search="${search}Unshelve\. Fail idtac\. "
search="${search}(Time )?Admitted\.$"
local repl='\1\2Qed.'
inplace_edit "s/^${search}$/${repl}/" "$@"
}
reverse=false
usage() {
echo "Usage: disable-qed.sh [--undo] <files>"
}
case "$1" in
"--undo" )
reverse=true
shift
;;
esac
if [ $reverse = true ]; then
backward_repl "$@"
else
forward_repl "$@"
fi