-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathdgibson.sh
More file actions
executable file
·61 lines (54 loc) · 1.06 KB
/
dgibson.sh
File metadata and controls
executable file
·61 lines (54 loc) · 1.06 KB
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
61
#!/usr/bin/env bash
#
# dgibson.sh - run the IOCCC entry 1993/dgibson
#
# usage:
# dgibson.sh [data_file]
# parse args
#
if [[ $# -eq 0 ]]; then
DATA="./dgibson.data1"
else
DATA="$1"
fi
if [[ ! -f "$DATA" ]]; then
echo "$0: no data found in $DATA" 1>&2
exit 1
fi
# for the initial data.name if needed
#
if [[ ! -f "data.name" ]]; then
rm -f data.name
echo "$DATA" > data.name
fi
if [[ ! -f life.d ]]; then
# force a new life setup
echo "/" > data.name
fi
rm -f data.name2
echo "$DATA" > data.name2
# note if we are running a new form
#
if cmp -s data.name data.name2; then
:
else
rm -f life.d
cp "$DATA" life.d
rm -f data.name
echo "$DATA" > data.name
cat life.d
fi
# build a new copy of the program
#
rm -f dgibson
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
# this way allows us to have the user specify a different compiler in an easy
# way.
if [[ -z "$CC" ]]; then
CC="cc"
fi
make CC="$CC" all >/dev/null || exit 1
# form the next generation
#
chmod +w life.d
./dgibson | tee life.d