Files
ioccc/2020/ferguson2/try.alt.sh
T
Cody Boone Ferguson 205fa25ced Change references of many terms to new names
This is a HUGE commit and this task is not done. There are still some
changes that might need to be discussed and since so much is done here I
think it's better to let this go through and then make sure everything
is okay. When the remaining references are discussed they can also be
changed.

I did NOT include changes in the tmp/OLD_manifest directory.

Some of the changes in this commit (it might be exhaustive but it might
not be - not sure):

- In the Makefiles the WINNERS was renamed AUTHORS.
- References to winners.html were changed to authors.html.
- The FAQ named anchor 'fix_a_winner' was renamed 'fix_an_entry'.
- The JSON fields (or whatever they're called) 'winner_id' and
'winner_JSON_format_version' were changed so that 'winner' is 'entry'.
- In scripts for entries 'IOCCC winner' was changed to 'IOCCC entry'.
- 'winners_text' is now 'entries_text'. It might be better to be
'entry_text' as it's per entry but this was not noticed at first. Since
this is easy to fix I am holding off on this for the meantime.
- The script tmp/update-manifest.sh now has the commit log messages
changed to the correct terms as well.

The index.html files were updated as well with any of the above
changes.

There are some references that should NOT be updated. Two examples
caught (and maybe more have slipped through that will have to be changed
back): in 1984/anonymous/README.md the author wrote back to Landon after
being told about the famous tattoo and they used the words:

    .. my entry will be the first IOCCC winner ..

but since this comes from the author it should remain so.

The other one is that winners.html should still refer to winners.html as
it informs people that it's been moved to authors.html (it does redirect
too but even so if it was changed it would defeat the purpose of the
message).

With paths like authors.html I tried to copy paste so that hopefully
there are no typos. It is possible that I did not end up doing this with
all but these can be fixed when discovered.
2024-02-13 07:31:36 -08:00

143 lines
5.4 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC entry 2020/ferguson2
#
# I, Cody Boone Ferguson, want to dedicate this entry in part to the millions of
# poor souls that were lost during the tragedy that is the Second World War.
# There are so many people who are unknown, unloved, unclaimed and even
# unidentified. And who knows what they might have gone on to do if their lives
# weren't - like it is with all other wars - needlessly taken from them? When
# one considers it was all because the most powerful man in the world at the
# time felt he should rule all others it makes it somehow even more tragic:
# there wasn't even a good reason for the war (is there ever?).
#
# If one were to write the name of every person who died in the conflict in a
# book, it would take so many pages that the book would be so heavy, so long, so
# expensive to print and it wouldn't bring anyone back to life nor would it erase
# the suffering. Nothing will. It's horrible.
#
# There really are no words that can truly describe the tragedy but I wish to
# with my Enigma simulator honour each and every soul who was lost, or suffered,
# or suffered the loss of friends or loved ones, as well as the world itself, in
# and from one of the greatest tragedies in the history of mankind.
#
# 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" everything >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
# IOCCC obfuscated!
read -r -n 1 -p "Press any key to encrypt IOCCC with default settings: "
echo 1>&2
echo "$ echo IOCCC | ./prog.alt" 1>&2
echo IOCCC | ./prog.alt
echo 1>&2
# IOCCC obfuscated and de-obfuscated!:
read -r -n 1 -p "Press any key to encrypt and then decrypt IOCCC with default settings: "
echo 1>&2
echo "$ echo IOCCC | ./prog | ./prog.alt" 1>&2
echo IOCCC | ./prog | ./prog.alt
echo 1>&2
# more input fun:
read -r -n 1 -p "Press any key to show try.this.txt: "
echo 1>&2
echo "$ cat try.this.txt" 1>&2
cat try.this.txt
read -r -n 1 -p "Press any key to encrypt text of try.this.txt with its own settings: "
echo 1>&2
echo "$ ./prog.alt - < try.this.txt 2>/dev/null" 1>&2
echo 1>&2
./prog.alt - < try.this.txt 2>/dev/null
echo 1>&2
# even more input fun:
read -r -n 1 -p "Press any key to show key.txt: "
echo 1>&2
echo "$ cat key.txt" 1>&2
cat key.txt
echo 1>&2
read -r -n 1 -p "Press any key to encrypt IOCCC with code of key.txt: "
echo 1>&2
echo "$ echo IOCCC | ./recode -v -Rkey.txt | ./prog.alt - 2>/dev/null" 1>&2
echo IOCCC | ./recode -v -Rkey.txt | ./prog.alt - 2>/dev/null
echo 1>&2
# now decrypt IOCCC with settings of key.txt by piping it back to recode -> prog.alt
read -r -n 1 -p "Press any key to encrypt and then decrypt IOCCC with code of key.txt: "
echo 1>&2
echo "$ echo IOCCC | ./recode -v -Rkey.txt | ./prog - 2>/dev/null | ./recode -Rkey.txt | ./prog.alt - 2>/dev/null" 1>&2
echo IOCCC | ./recode -v -Rkey.txt | ./prog - 2>/dev/null | ./recode -Rkey.txt | ./prog.alt - 2>/dev/null
echo 1>&2
# more obfuscated fun:
read -r -n 1 -p "Press any key to send 'testing test tests' to recode: "
echo 1>&2
echo "$ echo testing test tests | ./recode -v" 1>&2
echo testing test tests | ./recode -v
echo 1>&2
read -r -n 1 -p "Press any key to send 'testing test tests' to recode -> prog.alt: "
echo 1>&2
echo "$ echo testing test tests | ./recode -v | ./prog.alt - 2>/dev/null" 1>&2
echo testing test tests | ./recode -v | ./prog.alt - 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to send 'testing test tests' to recode -> prog -> recode: "
echo 1>&2
echo "$ echo testing test tests | ./recode -v | ./prog - 2>/dev/null | ./recode" 1>&2
echo testing test tests | ./recode -v | ./prog - 2>/dev/null | ./recode -v
echo 1>&2
read -r -n 1 -p "Press any key to send 'testing test tests' to recode -> prog -> recode -> prog.alt: "
echo 1>&2
echo "$ echo testing test tests | ./recode -v | ./prog - 2>/dev/null | ./recode -v | ./prog.alt - 2>/dev/null" 1>&2
echo testing test tests | ./recode -v | ./prog - 2>/dev/null | ./recode -v | ./prog.alt - 2>/dev/null
echo 1>&2
# even more obfuscated fun saving and reading from files:
#
# initial clean up:
rm -f conf input output output2
# encrypt "testing test tests" with randomised settings saved in conf, saving
# original string to input and original output to output:
read -r -n 1 -p "Press any key to save settings and output, then encrypt: "
echo 1>&2
echo "$ echo testing test tests | tee input | ./recode -v -r -oconf | ./prog - 2>/dev/null >output" 1>&2
echo testing test tests | tee input | ./recode -v -r -oconf | ./prog - 2>/dev/null >output
read -r -n 1 -p "Press any key to show input file: "
echo 1>&2
cat input
echo 1>&2
read -r -n 1 -p "Press any key to show output file: "
echo 1>&2
cat output
echo 1>&2
# configure Enigma machine from conf file and read from output file, thus decrypting:
read -r -n 1 -p "Press any key to decrypt the output from the above command: "
echo 1>&2
echo "$ ./recode -v -Rconf -foutput | ./prog - 2>/dev/null > output2" 1>&2
./recode -v -Rconf -foutput | ./prog - 2>/dev/null > output2
read -r -n 1 -p "Press any key to show output2: "
echo 1>&2
cat output2
read -r -n 1 -p "Press any key to show input again: "
echo 1>&2
cat input
echo 1>&2
# make sure input and output2 are the same:
read -r -n 1 -p "Press any key to compare input and output2: "
echo 1>&2
diff -s input output2
# final clean up
rm -f conf input output output2