Add 1992/adrian/try.sh

This script shows the entry itself as well as some of the other tools
that the entry generates. The adwc / wc one uses a pipeline to show the
output (with leading spaces and filename removed along with squeezing
spaces) and also writes each to a text file to use diff on, to show how
they have the same output.

Not all the tools are in the script. The adbasename might have a bug
(in any case it doesn't appear to function exactly like basename(1) in
that it requires two args, not one) so it is not used and adgrep is not
used either. For the latter one the author's remarks might provide some
clues as to why I did not include it.
This commit is contained in:
Cody Boone Ferguson committed 2024-01-14 09:46:54 -08:00
1 parent 85a9066b02
commit 094a4da91a
4 files changed
+76 -11

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1992/adrian
#
# 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
# don't redirect output to /dev/null so that they can see how it's done,
# assuming it's not already built
make CC="$CC" everything || exit 1
# DON'T clear the screen so they can see how the files are generated!
echo 1>&2
read -r -n 1 -p "Press any key to show: adrian.grep.try: "
echo 1>&2
cat adrian.grep.try
echo 1>&2
read -r -n 1 -p "Press any key to run: ./adrian adrian.grep.try < README.md: "
echo 1>&2
./adrian adrian.grep.try < README.md
echo 1>&2
read -r -n 1 -p "Press any key to run: ./adhead try.sh: "
echo 1>&2
./adhead try.sh
echo 1>&2
read -r -n 1 -p "Press any key to run: ./adecho 1992 IOCCC adrian: "
echo 1>&2
./adecho 1992 IOCCC adrian
echo 1>&2
rm -f wc.adwc.txt adwc.adwc.txt
echo "$ wc adwc.c | sed -e 's/^[[:space:]]//g' | tr -s '[:space:]' | cut -d' ' -f1-3 | tee wc.adwc.txt" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
wc adwc.c | sed -e 's/^[[:space:]]//g' | tr -s '[:space:]' | cut -d' ' -f1-3 | tee wc.adwc.txt
echo 1>&2
echo "$ ./adwc adwc.c|tr -s ' '|sed -e 's/^[[:space:]]//g' | tee adwc.adwc.txt" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./adwc adwc.c|tr -s ' '|sed -e 's/^[[:space:]]//g' | tee adwc.adwc.txt
echo 1>&2
read -r -n 1 -p "Press any key to show diff between wc.adwc.txt and adwc.adwc.txt: "
echo 1>&2
diff -s wc.adwc.txt adwc.adwc.txt
echo 1>&2
rm -f wc.adwc.txt adwc.adwc.txt
echo "$ ./adsleep 10" 1>&2
read -r -n 1 -p "Press any key to take a 10 second nap: "
echo 1>&2
./adsleep 10