Add try.sh to 1985/sicherman

The Makefile was also modified to have a sicherman.alt rule as it
requires -traditional-cpp. There is an argument that this should be
removed and instead the alt2 version (which is compiled if a compiler
fails to compile sicherman.c because of the 'wrong' number of args to
main() - one arg) would become the alt version because if someone wants
to try the original code they can look at sicherman.orig.c. This can be
done another time if it's worth doing (which I think it might be).
This commit is contained in:
Cody Boone Ferguson committed 2023-12-23 09:07:49 -08:00
1 parent ec71d8ad68
commit 53fb889475
4 files changed
+65 -19

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1985/sicherman
#
# 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: ./sicherman < sicherman.c: "
echo 1>&2
./sicherman < sicherman.c
echo 1>&2
read -r -n 1 -p "Press any key to run: echo IOCCC | ./sicherman: "
echo 1>&2
echo IOCCC | ./sicherman
echo 1>&2
read -r -n 1 -p "Press any key to run: ./sicherman < sicherman.c | ./sicherman: "
echo 1>&2
./sicherman < sicherman.c | ./sicherman
echo 1>&2
read -r -n 1 -p "Press any key to run: ./sicherman < sicherman.c | ./sicherman | diff -s - sicherman.c: "
echo 1>&2
./sicherman < sicherman.c | ./sicherman | diff -s - sicherman.c