chiark / gitweb /
move into misc-data.pl: NZ from generate-plag
[pandemic-rising-tide.git] / maybe-rerun-optim
1 #!/bin/bash
2 set -e
3 set -o posix
4 set -o pipefail
5
6 input=$1        ; shift
7 planar_graph=$1 ; shift
8 dest=$1         ; shift
9 sums=$1         ; shift
10
11 inst () { mv -vf $dest.tmp $dest; }
12
13 if test -f $dest.reuse; then
14         cp -v $dest.reuse $dest.tmp
15         inst
16         exit 0
17 fi
18
19 sha256sum "$input" "$planar_graph" >$sums.tmp
20 for arg in "$@"; do printf >>$sums.tmp "%s\n" "$arg"; done
21
22 if cmp $sums.tmp $sums; then
23         exit 0
24 fi
25
26 "$planar_graph" <$input "$@"
27
28 inst
29 mv -f $sums.tmp $sums