Add 1992/gson/try.sh, add note about optimiser
The optimiser must be disabled due to it otherwise crashing in macOS in some invocations. This has been added to the Makefile, the use of -O0 is forced and a note has been added to the README.md file. The bugs.md file has been updated on details of how it uses gets() and that text has been removed from the thanks file. Minor format fixes in README.md. The script added makes use of the author's script (that I added as mkdict.sh for easier use) after first trying to find a dictionary file. But one can override the dictionary file with the DICT environmental variable. This entry should now truly be done.
This commit is contained in:
1 parent
fed6b32f0a
commit
54c5271117
5 files changed
+158
-20
No files matched your search
Executable
+123
@@ -0,0 +1,123 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1992/gson
|
||||
#
|
||||
|
||||
# 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
|
||||
|
||||
# attempt to find a dictionary file if DICT unset or not a regular readable file
|
||||
#
|
||||
if [[ -z "$DICT" || ! -f "$DICT" || ! -r "$DICT" ]]; then
|
||||
DICT="/usr/share/dict/words"
|
||||
|
||||
if [[ ! -r "$DICT" ]]; then
|
||||
DICT="/usr/share/lib/spell/words"
|
||||
|
||||
if [[ ! -r "$DICT" ]]; then
|
||||
DICT="/usr/ucblib/dict/words"
|
||||
|
||||
if [[ ! -r "$DICT" ]]; then
|
||||
DICT="/dev/null"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# safety check that DICT is not empty and is a readable file
|
||||
#
|
||||
if [[ -z "$DICT" || ! -f "$DICT" || ! -r "$DICT" ]]; then
|
||||
echo "No dictionary file found, try specifying one like:" 1>&2
|
||||
echo 1>&2
|
||||
echo " DICT=dict ./try.sh" 1>&2
|
||||
echo 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$ ./ag free software foundation < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag free software foundation < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag obfuscated c contest < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag obfuscated c contest < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag unix international < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag unix international < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag george bush < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag george bush < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag bill clinton < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag bill clinton < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag ross perot < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag ross perot < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag paul e tsongas < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag paul e tsongas < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
# now try making our own dictionary with mkdict.sh:
|
||||
#
|
||||
rm -f words
|
||||
cat README.md try.sh Makefile | ./mkdict.sh > words
|
||||
DICT="words"
|
||||
|
||||
read -r -n 1 -p "Press any key to use our own dict from mkdict.sh: "
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./ag free software foundation < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag free software foundation < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag obfuscated c contest < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag obfuscated c contest < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag unix international < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag unix international < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag george bush < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag george bush < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag bill clinton < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag bill clinton < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag ross perot < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag ross perot < "$DICT" 2>/dev/null | less -rEXF
|
||||
|
||||
echo "$ ./ag paul e tsongas < $DICT" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||
echo 1>&2
|
||||
./ag paul e tsongas < "$DICT" 2>/dev/null | less -rEXF
|
||||
Reference in new issue
Block a user