Add 1990/scjones/try.sh

The script allows one to more easily see (and verify) what the entry
does. This involves a temporary file that is created (and removed at the
end of the script but which has also been added to .gitignore).
This commit is contained in:
Cody Boone Ferguson committed 2024-01-12 09:19:07 -08:00
1 parent 9a69a9dd24
commit 3065fc20d8
4 files changed
+46

No files matched your search

+1
View File
@@ -7,3 +7,4 @@ indent.o
prog.orig
scjones
scjones.orig
scjones.tmp.c
+7
View File
@@ -12,6 +12,13 @@ make all
```
## Try:
```sh
./try.sh
```
## Judges' remarks:
The addition of trigraphs has made it easier to make programs hard to read. It
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1990/scjones
#
# 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 show scjones.c: "
echo 1>&2
less -rEXF scjones.c
echo 1>&2
read -r -n 1 -p "Press any key to run: ./scjones (space = next page, q = quit): "
echo 1>&2
./scjones | less -rEXF
read -r -n 1 -p "Press any key to run: ./scjones > scjones.tmp.c: "
echo 1>&2
./scjones > scjones.tmp.c
echo 1>&2
read -r -n 1 -p "Press any key to compare scjones.c and scjones.tmp.c: "
echo 1>&2
diff -s scjones.c scjones.tmp.c
rm scjones.tmp.c