-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathtry.sh
More file actions
executable file
·79 lines (66 loc) · 2.57 KB
/
try.sh
File metadata and controls
executable file
·79 lines (66 loc) · 2.57 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC entry 2001/westley
#
# 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
# clear screen after compilation so that only the entry is shown
clear
read -r -n 1 -p "Press any key to run: ./westley < westley.c (space = next page, q = quit): "
echo 1>&2
./westley < westley.c 2>/dev/null | tee westley2.c | less -rEXFK
echo "Compiling westley2.c..." 1>&2
make CC="$CC" westley2 2>/dev/null 1>&2
echo 1>&2
echo "$ echo 'Bozos, please deflate shoes before entering the bus!'| ./westley2"
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
echo 'Bozos, please deflate shoes before entering the bus!'| ./westley2 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: make CC=\"$CC\" westley.sort 2>/dev/null: "
echo 1>&2
make CC="$CC" westley.sort 2>/dev/null 1>&2
echo 1>&2
echo "$ ./westley.sort < westley.c 2>/dev/null | diff -s - westley.c"
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
# There isn't a read and write problem.
#
# SC2094 (info): Make sure not to read and write the same file in the same pipeline.
# https://www.shellcheck.net/wiki/SC2094
# shellcheck disable=SC2094
./westley.sort < westley.c 2>/dev/null | diff -s - westley.c | less -rEXFK
echo 1>&2
echo "$ ./westley.sort < westley.c 2>/dev/null | diff - westley2.c"
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./westley.sort < westley.c 2>/dev/null | diff -s - westley2.c | less -rEXFK
echo 1>&2
echo "$ ./westley.sort < westley.c 2>/dev/null | diff - westley.sort.c"
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./westley.sort < westley.c 2>/dev/null | diff - westley.sort.c | less -rEXFK
echo 1>&2
echo "$ ./westley.sort < westley.c 2>/dev/null | diff - westley.punch.c"
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./westley.sort < westley.c 2>/dev/null | diff - westley.punch.c | less -rEXFK
echo 1>&2
read -r -n 1 -p "Press any key to run: printf \"1\n\4\n5\" | ./westley: "
echo 1>&2
printf "1\n4\n5" | ./westley 2>/dev/null
echo 1>&2
echo 1>&2
read -r -n 1 -p "Press any key to run: printf \"1\n4\n5\" | ./westley: "
echo 1>&2
printf "1\n4\n5" | ./westley 2>/dev/null
echo 1>&2
echo 1>&2
read -r -n 1 -p "Press any key to run: echo 'Hello, world!' | ./westley.punch: "
echo 1>&2
echo 'Hello, world!' | ./westley.punch 2>/dev/null