Add 1987/hines/try.sh
The files goto.c and goto.txt were also added. The first one is a short file that is easy to see how many 'goto's there are and the goto.txt file has seven 'goto's and one 'Goto' to demonstrate that the program is case-sensitive. The .gitignore file was updated with 'goto' though the Makefile does not have (of course) a 'goto' rule as it's only there to have a C file which is easy to see how many 'goto's there are.
This commit is contained in:
1 parent
9223a14012
commit
bc7ebdaa4b
6 files changed
+61
-1
No files matched your search
@@ -1,6 +1,7 @@
|
||||
#
|
||||
# sort with: sort -d -u
|
||||
*.dSYM
|
||||
goto
|
||||
hines
|
||||
hines.alt
|
||||
hines.orig
|
||||
|
||||
@@ -15,7 +15,7 @@ make all
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
./hines hines.c
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
int main(void)
|
||||
{
|
||||
goto x;
|
||||
x: goto y;
|
||||
y: goto z;
|
||||
z: goto a;
|
||||
a: goto end;
|
||||
end: return 0;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Goto goto goto goto
|
||||
goto goto goto goto
|
||||
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1987/hines
|
||||
#
|
||||
|
||||
# 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
|
||||
|
||||
show()
|
||||
{
|
||||
if [[ "$#" -ne 1 ]]; then
|
||||
echo "$0: expected 1 arg to show(), got: $#" 1>&2
|
||||
return
|
||||
fi
|
||||
|
||||
read -r -n 1 -p "Press any key to show $1 (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
less -rEXF "$1"
|
||||
echo 1>&2
|
||||
|
||||
read -r -n 1 -p "Press any key to run: ./hines $1: "
|
||||
echo 1>&2
|
||||
./hines "$1"
|
||||
echo 1>&2
|
||||
}
|
||||
|
||||
show hines.c
|
||||
|
||||
show goto.c
|
||||
|
||||
show goto.txt
|
||||
Reference in new issue
Block a user