From b9f72adc4afa47739096f3d2e275011991c45486 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 27 May 2024 10:24:24 -0700 Subject: [PATCH] Improve 1996/schweikh2/try.sh As I was going through another file I noticed that something was missing from the script, if perl is installed, and it also prompts the user if they wish to run the author's suggested command (it results in an infinite loop which is why it was left out but prompting for it is okay as it's at the end). The make clobber rule was updated for this update. --- 1996/schweikh2/Makefile | 1 + 1996/schweikh2/README.md | 4 ++++ 1996/schweikh2/index.html | 3 +++ 1996/schweikh2/try.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 35 insertions(+) diff --git a/1996/schweikh2/Makefile b/1996/schweikh2/Makefile index 9f7b36c43..e438813d4 100644 --- a/1996/schweikh2/Makefile +++ b/1996/schweikh2/Makefile @@ -203,6 +203,7 @@ clean: clobber: clean ${RM} -f ${TARGET} ${ALT_TARGET} ${RM} -rf *.dSYM + ${RM} -f obfus.c @-if [ -e sandwich ]; then \ ${RM} -f sandwich; \ echo 'ate sandwich'; \ diff --git a/1996/schweikh2/README.md b/1996/schweikh2/README.md index bf4d88267..339033c75 100644 --- a/1996/schweikh2/README.md +++ b/1996/schweikh2/README.md @@ -57,6 +57,10 @@ appropriately. Try: perl ./hunni.pl < hunni.c ``` +NOTE: the [try.sh](%%REPO_URL%%/1996/schweikh2/try.sh) does this if you have +`perl(1)` installed to show how the output is the same as +[schweikh2.c](%%REPO_URL%%/1996/schweikh2/schweikh2.c) itself. + This entry was another crowd pleaser at the IOCCC BOF. diff --git a/1996/schweikh2/index.html b/1996/schweikh2/index.html index a90f3cffb..be392dbae 100644 --- a/1996/schweikh2/index.html +++ b/1996/schweikh2/index.html @@ -422,6 +422,9 @@ appropriately. Try:

    less hunni.c
 
     perl ./hunni.pl < hunni.c
+

NOTE: the try.sh does this if you have +perl(1) installed to show how the output is the same as +schweikh2.c itself.

This entry was another crowd pleaser at the IOCCC BOF.

Author’s remarks:

Note: the source must be viewed with tabstop 8. To appreciate the diff --git a/1996/schweikh2/try.sh b/1996/schweikh2/try.sh index 6e8fc68da..da7a34f41 100755 --- a/1996/schweikh2/try.sh +++ b/1996/schweikh2/try.sh @@ -29,3 +29,30 @@ read -r -n 1 -p "Press any key to run grep -v '#' schweikh2.c (space = next page echo 1>&2 grep -v '#' schweikh2.c | less -rEXF echo 1>&2 + +PERL="$(type -P perl)" +if [[ -n "$PERL" ]]; then + read -r -n 1 -p "Press any key to run: less hunni.c (space = next page, q = quit): " + echo 1>&2 + less -rEXF hunni.c + echo 1>&2 + + echo "$ perl ./hunni.pl < hunni.c > obfus.c" 1>&2 + read -r -n 1 -p "Press any key to obfuscate hunni.c as obfus.c (space = next page, q = quit): " + echo 1>&2 + perl ./hunni.pl < hunni.c > obfus.c + + read -r -n 1 -p "Press any key to run: diff -s obfus.c schweikh2.c: " + echo 1>&2 + diff -s obfus.c schweikh2.c + rm -f obfus.c +fi + +read -r -p "Do you want to run the author's suggested command (Y/N)? " +if [[ "$REPLY" = "y" || "$REPLY" = "Y" ]]; then + echo "Warning: this command is an infinite loop. Press ctrl-c or whatever your" 1>&2 + echo "intr is to end it." 1>&2 + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 + while :; do grep -v '#' schweikh2.c; sleep 2; echo; done +fi