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.
This commit is contained in:
Cody Boone Ferguson committed 2024-07-20 13:15:04 -07:00
1 parent e76286921b
commit 967cd60b18
3 files changed
+86 -74

No files matched your search

+15 -21
View File
@@ -21,7 +21,7 @@ For more detailed information see [1992/gson in bugs.html](../../bugs.html#1992_
## To use:
``` <!---sh-->
./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:
+14 -21
View File
@@ -419,34 +419,27 @@ some invocations to crash in some systems.</p>
</blockquote>
<p>For more detailed information see <a href="../../bugs.html#1992_gson">1992/gson in bugs.html</a>.</p>
<h2 id="to-use">To use:</h2>
<pre><code> ./ag word word2 word3 &lt; dictionary</code></pre>
<pre><code> ./ag word word2 word3 &lt; dictionary | less</code></pre>
<h2 id="try">Try:</h2>
<pre><code> ./try.sh</code></pre>
<p>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:</p>
<p>The script first will use the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/mkdict.sh">mkdict.sh</a> script to create
a dictionary file out of the files
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/README.md">README.md</a>,
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/try.sh">try.sh</a> (itself) and
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/Makefile">Makefile</a> runs the program with a number of
strings on that dictionary file.</p>
<p>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:</p>
<ul>
<li><code>/usr/share/dict/words</code></li>
<li><code>/usr/share/lib/spell/words</code></li>
<li><code>/usr/ucblib/dict/words</code></li>
<li><code>/dev/null</code> # &lt;– for machines with nothing to say</li>
</ul>
<p>Then it runs the program with the following strings, using the proper dictionary
file:</p>
<ul>
<li><code>free software foundation</code></li>
<li><code>obfuscated c contest</code></li>
<li><code>unix international</code></li>
<li><code>george bush</code></li>
<li><code>bill clinton</code></li>
<li><code>ross perot</code></li>
<li><code>paul e tsongas</code></li>
</ul>
<p>Then it uses the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/mkdict.sh">mkdict.sh</a> script to create a dictionary file out
of the files <a href="README.md">README.md</a>, <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/try.sh">try.sh</a> (itself) and
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/Makefile">Makefile</a> 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.</p>
<p>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.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>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!</p>
<p>The author provided an obfuscated script that can be used to construct
dictionaries which has been put in as <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/gson/mkdict.sh">mkdict.sh</a>. To use try:</p>
<pre><code> cat README.md | ./mkdict.sh &gt; words</code></pre>
<p>Then try using the program as shown above with the file <code>words</code>.</p>
<p>Then try using the program <a href="#to-use">as shown above</a> with the file <code>words</code>.</p>
<h2 id="authors-remarks">Author’s remarks:</h2>
<p>The name of the game:</p>
<p><code>AG</code> is short for either <code>Anagram Generator</code> or simply <code>AnaGram</code>. It might also be
+57 -32
View File
@@ -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