From 967cd60b184446afd3a96f94a2c604dca3691e18 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Sat, 20 Jul 2024 13:01:18 -0700 Subject: [PATCH] Improve 1992/gson/try.sh + fix index.html For fun more strings have been added and the dictionary constructed with mkdict.sh now uses index.html as well. Some fun anagrams that might amuse some people, some from the program and some that I noticed: free software foundations: foundation was set for free foundations for free waste unix international: relaxation unit inn nun relaxation in it inline no tar at unix bill gates: stale glib free software foundation (software): routine and waste offer of (software) idea for fun software note microsoft conspiracy: try ansi op forms ioccc any op first forms ioccc international microsoft conspiracy: first conspiracy container main tool force locations contains primary tin but there are plenty others to find with the script and otherwise. --- 1992/gson/README.md | 36 ++++++++---------- 1992/gson/index.html | 35 +++++++---------- 1992/gson/try.sh | 89 ++++++++++++++++++++++++++++---------------- 3 files changed, 86 insertions(+), 74 deletions(-) diff --git a/1992/gson/README.md b/1992/gson/README.md index 2b246b7d9..158149c97 100644 --- a/1992/gson/README.md +++ b/1992/gson/README.md @@ -21,7 +21,7 @@ For more detailed information see [1992/gson in bugs.html](../../bugs.html#1992_ ## To use: ``` - ./ag word word2 word3 < dictionary + ./ag word word2 word3 < dictionary | less ``` @@ -31,31 +31,25 @@ For more detailed information see [1992/gson in bugs.html](../../bugs.html#1992_ ./try.sh ``` -This script will determine (or try and determine) where your system dictionary -is located and assuming that it can find one it'll use that. It checks the -following locations though the last one is more ironic: +The script first will use the [mkdict.sh](%%REPO_URL%%/1992/gson/mkdict.sh) script to create +a dictionary file out of the files +[README.md](%%REPO_URL%%/1992/gson/README.md), +[try.sh](%%REPO_URL%%/1992/gson/try.sh) (itself) and +[Makefile](%%REPO_URL%%/1992/gson/Makefile) runs the program with a number of +strings on that dictionary file. + +Then the script will determine (or try and determine) where your system +dictionary is located and assuming that it can find one it'll use that. It +checks the following locations though the last one is more ironic: * `/usr/share/dict/words` * `/usr/share/lib/spell/words` * `/usr/ucblib/dict/words` * `/dev/null` # <-- for machines with nothing to say -Then it runs the program with the following strings, using the proper dictionary -file: - -* `free software foundation` -* `obfuscated c contest` -* `unix international` -* `george bush` -* `bill clinton` -* `ross perot` -* `paul e tsongas` - -Then it uses the [mkdict.sh](%%REPO_URL%%/1992/gson/mkdict.sh) script to create a dictionary file out -of the files [README.md](README.md), [try.sh](%%REPO_URL%%/1992/gson/try.sh) (itself) and -[Makefile](%%REPO_URL%%/1992/gson/Makefile) and it repeats the same process as above. In the case no -dictionary file can be found in the first step it only runs the commands once -with the created dictionary file. +If a file is found then it will run the same process as above. The reason the +made up dictionary is used first is it provides shorter and a bit more fun +output. ## Judges' remarks: @@ -71,7 +65,7 @@ dictionaries which has been put in as [mkdict.sh](%%REPO_URL%%/1992/gson/mkdict. cat README.md | ./mkdict.sh > words ``` -Then try using the program as shown above with the file `words`. +Then try using the program [as shown above](#to-use) with the file `words`. ## Author's remarks: diff --git a/1992/gson/index.html b/1992/gson/index.html index 6c3b3f914..b1baa36b9 100644 --- a/1992/gson/index.html +++ b/1992/gson/index.html @@ -419,34 +419,27 @@ some invocations to crash in some systems.

For more detailed information see 1992/gson in bugs.html.

To use:

-
    ./ag word word2 word3 < dictionary
+
    ./ag word word2 word3 < dictionary | less

Try:

    ./try.sh
-

This script will determine (or try and determine) where your system dictionary -is located and assuming that it can find one it’ll use that. It checks the -following locations though the last one is more ironic:

+

The script first will use the mkdict.sh script to create +a dictionary file out of the files +README.md, +try.sh (itself) and +Makefile runs the program with a number of +strings on that dictionary file.

+

Then the script will determine (or try and determine) where your system +dictionary is located and assuming that it can find one it’ll use that. It +checks the following locations though the last one is more ironic:

-

Then it runs the program with the following strings, using the proper dictionary -file:

- -

Then it uses the mkdict.sh script to create a dictionary file out -of the files README.md, try.sh (itself) and -Makefile and it repeats the same process as above. In the case no -dictionary file can be found in the first step it only runs the commands once -with the created dictionary file.

+

If a file is found then it will run the same process as above. The reason the +made up dictionary is used first is it provides shorter and a bit more fun +output.

Judges’ remarks:

Recently some newspapers printed amusing anagrams of one of the names listed above. Run this program to find the anagrams they @@ -454,7 +447,7 @@ weren’t allowed to print!

The author provided an obfuscated script that can be used to construct dictionaries which has been put in as mkdict.sh. To use try:

    cat README.md | ./mkdict.sh > words
-

Then try using the program as shown above with the file words.

+

Then try using the program as shown above with the file words.

Author’s remarks:

The name of the game:

AG is short for either Anagram Generator or simply AnaGram. It might also be diff --git a/1992/gson/try.sh b/1992/gson/try.sh index b61718849..897c75fed 100755 --- a/1992/gson/try.sh +++ b/1992/gson/try.sh @@ -15,8 +15,51 @@ 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 +ag() +{ + if [[ "$#" -lt 2 ]]; then + echo "$0: ag() requires at least two args, given: $#" 1>&2 + return + fi + + echo "$ ./ag -5 ${*:2} < $1" 1>&2 + read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " + echo 1>&2 + ./ag -5 "${@:2}" < "$1" 2>/dev/null | less -rEXF + + echo 1>&2 +} + +# try making our own dictionary with mkdict.sh: # +rm -f words +cat index.html README.md try.sh Makefile | ./mkdict.sh > words +DICT="words" + +# safety check that DICT is not empty and is a readable file +# +if [[ -n "$DICT" && -f "$DICT" && -r "$DICT" ]]; then + read -r -n 1 -p "Press any key to use our own dict from mkdict.sh: " + echo 1>&2 + ag "$DICT" free software foundation + ag "$DICT" free software foundations + ag "$DICT" obfuscated c contest + ag "$DICT" obfuscated c contests + ag "$DICT" unix international + ag "$DICT" george bush + ag "$DICT" ross perot + ag "$DICT" paul e tsongas + ag "$DICT" bill gates + ag "$DICT" microsoft conspiracy + ag "$DICT" international microsoft conspiracy +fi + +# now attempt to find a dictionary file if DICT unset or not a regular readable file +# +echo "Will now try locating system dictionary." 1>&2 +read -r -n 1 -p "Press any key to continue: " +echo 1>&2 +DICT="" if [[ -z "$DICT" || ! -f "$DICT" || ! -r "$DICT" ]]; then DICT="/usr/share/dict/words" @@ -33,45 +76,27 @@ if [[ -z "$DICT" || ! -f "$DICT" || ! -r "$DICT" ]]; then fi fi -ag() -{ - if [[ "$#" -lt 2 ]]; then - echo "$0: ag() requires at least two args, given: $#" 1>&2 - return - fi - - echo "$ ./ag ${*:2} < $1" 1>&2 - read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " - echo 1>&2 - ./ag "${@:2}" < "$1" 2>/dev/null | less -rEXF - - echo 1>&2 -} # safety check that DICT is not empty and is a readable file # if [[ -n "$DICT" && -f "$DICT" && -r "$DICT" ]]; then + echo "Using $DICT as dictionary file." 1>&2 + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 ag "$DICT" free software foundation + ag "$DICT" free software foundations ag "$DICT" obfuscated c contest + ag "$DICT" obfuscated c contests ag "$DICT" unix international ag "$DICT" george bush ag "$DICT" bill clinton ag "$DICT" ross perot ag "$DICT" paul e tsongas + ag "$DICT" pauline hansen + ag "$DICT" bill gates + ag "$DICT" microsoft windows + read -r -n 1 -p "This next one can take some time. Do you want to run it anyway (Y/N)? " + echo 1>&2 + if [[ "$REPLY" = "y" || "$REPLY" = "Y" ]]; then + ag "$DICT" international microsoft conspiracy + fi fi - -# 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 -ag "$DICT" free software foundation -ag "$DICT" obfuscated c contest -ag "$DICT" unix international -ag "$DICT" george bush -ag "$DICT" bill clinton -ag "$DICT" ross perot -ag "$DICT" paul e tsongas -