Fix and improve 2001/anonymous/try.sh

It previously would abort if anonymous couldn't be built but this was an
error because it will at least run the supplementary program even if the
entry or supplementary program cannot be compiled in 32-bit.

Get CC, defaulting to cc.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-14 04:12:18 -08:00
1 parent d73b80bd96
commit fc0751ea94
1 file changed
+16 -1
+16 -1
View File
@@ -1,7 +1,21 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2001/anonymous
#
make clobber alt all >/dev/null 2>&1
# 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
# in this case we won't fail if we can't compile the code because we can still
# run the supplementary program.
make CC="$CC" everything >/dev/null
# clear screen after compilation so that only the entry is shown
clear
TARGET="anonymous.ten"
if [[ -f "$TARGET" ]]; then
@@ -28,6 +42,7 @@ if [[ -f "$TARGET" ]]; then
else
echo "cannot compile anonymous.ten.c as 32-bit, sorry."
echo "will run 64-bit version directly."
make anonymous.ten.64
sleep 3
echo "$ ./$TARGET.64"
./"$TARGET".64