Add 2011/fredriksson/try.sh + format/typo checks

Before the last command that the try.sh script will do it first tries to
set the stack size to unlimited (for the process) and if it fails it
won't run the last command as it will likely dump core.

Add entry to bugs.md but since there are quite a few things I just
linked to the author's remarks (the sections). This can be adjusted
another time if necessary.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-28 12:56:48 -08:00
1 parent d74f28879f
commit 30828808bc
4 files changed
+99 -19

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2011/fredriksson
#
# 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
echo "$ ./fredriksson -k3 cat < fredriksson.c" 1>&2
read -r -n 1 -p "Press any key to have the program show its source code: "
echo 1>&2
./fredriksson -k3 cat < fredriksson.c
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
read -r -n 1 -p "Press any key to run: ./fredriksson -k1 -i POOT < /etc/group: "
echo 1>&2
./fredriksson -k1 -i POOT < /etc/group
echo 1>&2
read -r -n 1 -p "Press any key to run: ./fredriksson -ck0 [0-9] < fredriksson.c: "
echo 1>&2
./fredriksson -ck0 [0-9] < fredriksson.c
echo 1>&2
read -r -n 1 -p "Press any key to run: ./fredriksson -ck0 [0-9] < ag.c: "
echo 1>&2
./fredriksson -ck0 [0-9] < ag.c
echo "Trying to set unlimited stack space for this process..." 1>&2
ulimit -s unlimited 2>/dev/null
if [[ "$?" -ne 0 ]]; then
echo "...couldn't set unlimited stack space, will skip command." 1>&2
else
read -r -n 1 -p "Press any key to run: ./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words: "
./fredriksson -k2 -t -n bofuskate < /usr/share/dict/words
fi