Improve 2012/omoikane/try scripts

This commit is contained in:
Cody Boone Ferguson committed 2024-01-26 10:42:14 -08:00
1 parent bf98cc9052
commit 86ee07db36
3 files changed
+55 -45

No files matched your search

+27 -21
View File
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2012/omoikane alternate code
# try.alt.sh - demonstrate IOCCC winner 2012/omoikane alt code
#
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
@@ -10,7 +10,7 @@ if [[ -z "$CC" ]]; then
CC="cc"
fi
make CC="$CC" everything >/dev/null || exit 1
make CC="$CC" alt >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
@@ -23,27 +23,29 @@ PERL="$(type -P perl)"
echo "$ echo \"A quick brown fox jumps over the lazy dog\" | ./nyaruko.alt > output.c" 1>&2
echo "A quick brown fox jumps over the lazy dog" | ./nyaruko.alt > output.c
read -r -n 1 -p "Press any key to run: less -EX output.c (space = next page, q = quit): "
read -r -n 1 -p "Press any key to show output.c (space = next page, q = quit): "
echo 1>&2
less -EX output.c
less -rEXFK output.c
# perl specific stuff
if [[ -n "$PERL" ]]; then
if [[ -n "$PERL" && -f "$PERL" && -x "$PERL" ]]; then
read -r -n 1 -p "Press any key to run: ${PERL} output.c > data.c: " 1>&2
echo 1>&2
"${PERL}" output.c > data.c
read -r -n 1 -p "Press any key to run: less -EX data.c (space = next page, q = quit): "
read -r -n 1 -p "Press any key to show data.c (space = next page, q = quit): "
echo 1>&2
less -rEXFK data.c
echo 1>&2
read -r -n 1 -p "Press any key to run: cc -o data data.c: "
echo 1>&2
less -EX data.c
echo "$ cc -o data data.c" 1>&2
cc -o data data.c
read -r -n 1 -p "Press any key to run: ./data: "
echo "$ ./data" 1>&2
echo 1>&2
./data
fi
echo "$ cc -o output output.c" 1>&2
read -r -n 1 -p "Press any key to run: cc -o output output.c: "
echo 1>&2
cc -o output output.c
read -r -n 1 -p "Press any key to run: ./output: "
echo 1>&2
@@ -53,37 +55,41 @@ echo "$ ./output" 1>&2
read -r -n 1 -p "Press any key to run: ./nyaruko.alt < output > output.c: "
echo 1>&2
./nyaruko.alt < output > output.c
read -r -n 1 -p "Press any key to run: less -EX output.c (space = next page, q = quit): "
read -r -n 1 -p "Press any key to show output.c (space = next page, q = quit): "
echo 1>&2
less -EX output.c
less -rEXFK output.c
read -r -n 1 -p "Press any key to run: bash output.c > key.c: "
echo 1>&2
bash output.c > key.c
echo 1>&2
read -r -n 1 -p "Press any key to run: less -EX key.c (space = next page, q = quit): "
less -EX key.c
read -r -n 1 -p "Press any key to run: show key.c (space = next page, q = quit): "
less -rEXFK key.c
# more perl stuff
if [[ -n "${PERL}" ]]; then
if [[ -n "${PERL}" && -f "$PERL" && -x "$PERL" ]]; then
read -r -n 1 -p "Press any key to run: ${PERL} output.c > data.c: "
echo 1>&2
"${PERL}" output.c > data.c
read -r -n 1 -p "Press any key to run: less -EX data.c (space = next page, q = quit): "
read -r -n 1 -p "Press any key to show data.c (space = next page, q = quit): "
echo 1>&2
less -EX data.c
less -rEXFK data.c
read -r -n 1 -p "Press any key to run: cat key.c data.c > output.c: "
echo 1>&2
cat key.c data.c > output.c
read -r -n 1 -p "Press any key to run: less -EX output.c (space = next page, q = quit): "
read -r -n 1 -p "Press any key to show output.c (space = next page, q = quit): "
echo 1>&2
less -rEXFK output.c
read -r -n 1 -p "Press any key to run: cc output.c -o output: "
echo 1>&2
less -EX output.c
echo "$ cc output.c -o output" 1>&2
cc output.c -o output
read -r -n 1 -p "Press any key to run: ./output > output.2: "
echo 1>&2
./output > output.2
echo "$ chmod +x output.2" 1>&2
read -r -n 1 -p "Press any key to run: chmod +x output.2: "
echo 1>&2
chmod +x output.2
read -r -n 1 -p "Press any key to run: ./output.2: "
echo 1>&2
./output.2
fi
+25 -19
View File
@@ -23,27 +23,29 @@ PERL="$(type -P perl)"
echo "$ echo \"A quick brown fox jumps over the lazy dog\" | ./nyaruko > output.c" 1>&2
echo "A quick brown fox jumps over the lazy dog" | ./nyaruko > output.c
read -r -n 1 -p "Press any key to run: less -EX output.c (space = next page, q = quit): "
read -r -n 1 -p "Press any key to show output.c (space = next page, q = quit): "
echo 1>&2
less -EX output.c
less -rEXFK output.c
# perl specific stuff
if [[ -n "$PERL" ]]; then
if [[ -n "$PERL" && -f "$PERL" && -x "$PERL" ]]; then
read -r -n 1 -p "Press any key to run: ${PERL} output.c > data.c: " 1>&2
echo 1>&2
"${PERL}" output.c > data.c
read -r -n 1 -p "Press any key to run: less -EX data.c (space = next page, q = quit): "
read -r -n 1 -p "Press any key to show data.c (space = next page, q = quit): "
echo 1>&2
less -rEXFK data.c
echo 1>&2
read -r -n 1 -p "Press any key to run: cc -o data data.c: "
echo 1>&2
less -EX data.c
echo "$ cc -o data data.c" 1>&2
cc -o data data.c
read -r -n 1 -p "Press any key to run: ./data: "
echo "$ ./data" 1>&2
echo 1>&2
./data
fi
echo "$ cc -o output output.c" 1>&2
read -r -n 1 -p "Press any key to run: cc -o output output.c: "
echo 1>&2
cc -o output output.c
read -r -n 1 -p "Press any key to run: ./output: "
echo 1>&2
@@ -53,37 +55,41 @@ echo "$ ./output" 1>&2
read -r -n 1 -p "Press any key to run: ./nyaruko < output > output.c: "
echo 1>&2
./nyaruko < output > output.c
read -r -n 1 -p "Press any key to run: less -EX output.c (space = next page, q = quit): "
read -r -n 1 -p "Press any key to show output.c (space = next page, q = quit): "
echo 1>&2
less -EX output.c
less -rEXFK output.c
read -r -n 1 -p "Press any key to run: bash output.c > key.c: "
echo 1>&2
bash output.c > key.c
echo 1>&2
read -r -n 1 -p "Press any key to run: less -EX key.c (space = next page, q = quit): "
less -EX key.c
read -r -n 1 -p "Press any key to run: show key.c (space = next page, q = quit): "
less -rEXFK key.c
# more perl stuff
if [[ -n "${PERL}" ]]; then
if [[ -n "${PERL}" && -f "$PERL" && -x "$PERL" ]]; then
read -r -n 1 -p "Press any key to run: ${PERL} output.c > data.c: "
echo 1>&2
"${PERL}" output.c > data.c
read -r -n 1 -p "Press any key to run: less -EX data.c (space = next page, q = quit): "
read -r -n 1 -p "Press any key to show data.c (space = next page, q = quit): "
echo 1>&2
less -EX data.c
less -rEXFK data.c
read -r -n 1 -p "Press any key to run: cat key.c data.c > output.c: "
echo 1>&2
cat key.c data.c > output.c
read -r -n 1 -p "Press any key to run: less -EX output.c (space = next page, q = quit): "
read -r -n 1 -p "Press any key to show output.c (space = next page, q = quit): "
echo 1>&2
less -rEXFK output.c
read -r -n 1 -p "Press any key to run: cc output.c -o output: "
echo 1>&2
less -EX output.c
echo "$ cc output.c -o output" 1>&2
cc output.c -o output
read -r -n 1 -p "Press any key to run: ./output > output.2: "
echo 1>&2
./output > output.2
echo "$ chmod +x output.2" 1>&2
read -r -n 1 -p "Press any key to run: chmod +x output.2: "
echo 1>&2
chmod +x output.2
read -r -n 1 -p "Press any key to run: ./output.2: "
echo 1>&2
./output.2
fi
+3 -5
View File
@@ -3820,17 +3820,15 @@ respectively. Notice how a single letter changes so much!
## <a name="2012_omoikane"></a>[2012/omoikane](/2012/omoikane/omoikane.c) ([README.md](/2012/omoikane/README.md]))
[Cody](#cody) added the [try.sh](/2012/omoikane/try.sh) script.
Cody also added the [alternate code](/2012/omoikane/README.md#alternate-code)
[Cody](#cody) added the [alternate versions](/2012/omoikane/README.md#alternate-code)
which will, if no arg is specified, read in the program itself, rather than
`/dev/urandom`. This is mostly useful for those without a `/dev/urandom` device
file (the default for the entry). The second alternate version is like the first
except that it also sets binary mode on `stdin` and `stdout` which should
theoretically make it work in Windows.
Cody also added the [try.alt.sh](/2012/omoikane/try.alt.sh) script that is like
the `try.sh` script but which uses the (first version of the) alt code instead.
Cody also added the [try.sh](/2012/omoikane/try.sh) and
[try.alt.sh](/2012/omoikane/try.alt.sh) scripts.
## <a name="2012_tromp"></a>[2012/tromp](/2012/tromp/tromp.c) ([README.md](/2012/tromp/README.md))