-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgen_levels_inc.bash
More file actions
executable file
·57 lines (49 loc) · 942 Bytes
/
gen_levels_inc.bash
File metadata and controls
executable file
·57 lines (49 loc) · 942 Bytes
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
#!/bin/bash
i="1"
l="0"
cd $1
if [ ! -d "src" ]
then
echo "Error: Directory \"src\" does not exist." >&2
exit 1
fi
rm -f src/levels.inc
if [ -f "src/levels.inc" ]
then
echo "Error: Could not delete file \"src/levels.inc\"." >&2
exit 1
fi
if [ ! -d "levels" ]
then
echo "Warning: Directory \"levels\" does not exist." >&2
echo > src/levels.inc
if [ -f "src/levels.inc" ]
then
exit 0
else
echo "Error: Could not create file \"src/levels.inc\"." >&2
exit 1
fi
fi
while [ -f "levels/level$i.inc" ]
do
echo "case $i:" >> src/levels.inc
echo "{" >> src/levels.inc
echo " #include \"../levels/level$i.inc\"" >> src/levels.inc
echo " break;" >> src/levels.inc
echo "}" >> src/levels.inc
i=$[$i+1]
l="1"
done
if [ $l -lt 1 ]
then
echo "Warning: Directory \"levels\" does not contain \"level1.inc\"." >&2
echo > src/levels.inc
fi
if [ -f "src/levels.inc" ]
then
exit 0
else
echo "Error: Could not create file \"src/levels.inc\"." >&2
exit 1
fi