From 047c97379f210976ac842877d33a0692eeed6379 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 27 Nov 2023 08:45:30 -0800 Subject: [PATCH] Format/typo check 2011/akari + improve try.sh --- 2011/akari/.gitignore | 2 ++ 2011/akari/README.md | 37 +++++++------------------------------ 2011/akari/try.sh | 32 +++++++++++++++++++++++++++++--- thanks-for-fixes.md | 5 +++++ 4 files changed, 43 insertions(+), 33 deletions(-) diff --git a/2011/akari/.gitignore b/2011/akari/.gitignore index bb124a066..806b97686 100644 --- a/2011/akari/.gitignore +++ b/2011/akari/.gitignore @@ -9,3 +9,5 @@ even_output.ppm odd_output.ppm akari.orig prog.orig +rot13.c +expanded_and_rot13_output.txt diff --git a/2011/akari/README.md b/2011/akari/README.md index 00a722cdc..4c7b6f9b2 100644 --- a/2011/akari/README.md +++ b/2011/akari/README.md @@ -14,30 +14,6 @@ make ### Try: -```sh -./akari < example.ppm > odd_output.ppm -./akari - - even < example.ppm > even_output.ppm -./akari example.ppm odd_output.ppm - -make akari2 -cat akari2.c - -./akari2 < akari2.c -./akari2 rot13 < akari2.c - -make akari3 -cat akari3.c - -./akari3 - -make akari4 -cat akari4.c - -./akari4 -``` - -You can automate the above by running: - ```sh ./try.sh ``` @@ -58,7 +34,7 @@ properly**_. `PPM` files with the header `P6 255` are accepted. * [ASCII art](https://en.wikipedia.org/wiki/ASCII_art) (with [end of -lines](https://en.wikipedia.org/wiki/Newline) in LF bytes only, _**not** CRLF_!) +lines](https://en.wikipedia.org/wiki/Newline) in LF bytes only, _**not** CR-LF_!) Anything that is not parsable as `PGM` or `PPM` will be downsampled as ASCII art. @@ -68,15 +44,16 @@ Anything that is not parsable as `PGM` or `PPM` will be downsampled as ASCII art `Akari` is an image downsampling utility. She accepts up to 3 arguments: The first argument is the input image. If it's `-` or unspecified, `Akari` -will read from stdin. +will read from `stdin`. The second argument is the output image. If it's `-` or unspecified, -`Akari` will write to stdout. +`Akari` will write to `stdout`. The third argument, if specified, causes `Akari` to keep even pixels on even [scanlines](https://en.wikipedia.org/wiki/Scan_line). By default `Akari` will keep odd pixels on odd [scanlines](https://en.wikipedia.org/wiki/Scan_line). + ### Examples: ```sh @@ -110,8 +87,8 @@ natural to try: ``` `akari2.c` is also a valid C program, and accepts up to 1 argument. -By default, this second program reads text from stdin and writes -expanded output to stdout. If the extra argument is specified, the +By default, this second program reads text from `stdin` and writes +expanded output to `stdout`. If the extra argument is specified, the output text will also pass through a rot13 filter. ```sh @@ -142,7 +119,7 @@ We must go deeper: `akari3.c` and `akari4.c` are still (mostly valid) C programs. `gcc -Wall` will output a few warnings, but still produce output -executables. The output executables each print a message to stdout. +executables. The output executables each print a message to `stdout`. It takes quite a bit of skill and obfuscation to interleave a C program 4 levels deep, it's much easier to interleave something like diff --git a/2011/akari/try.sh b/2011/akari/try.sh index 8c5846d1e..98053a63a 100755 --- a/2011/akari/try.sh +++ b/2011/akari/try.sh @@ -24,18 +24,44 @@ clear ./akari - - even < example.ppm > even_output.ppm ./akari example.ppm odd_output.ppm -make akari2 || exit 1 +make akari2 >/dev/null|| exit 1 +read -r -n 1 -p "Press any key to cat akari2.c: " cat akari2.c +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./akari2 < akari2.c: " ./akari2 < akari2.c +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./akari2 rot13 < akari2.c: " ./akari2 rot13 < akari2.c -make akari3 || exit 1 +make akari3 >/dev/null|| exit 1 + +read -r -n 1 -p "Press any key to cat akari3.c: " cat akari3.c +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./akari3: " ./akari3 +echo 1>&2 -make akari4 || exit 1 +make akari4 >/dev/null|| exit 1 + +read -r -n 1 -p "Press any key to cat akari4.c: " cat akari4.c +read -r -n 1 -p "Press any key to run: ./akari4: " ./akari4 +echo 1>&2 + +read -r -n 1 -p "Press any key to run: ./akari2 rot13 < akari.c | ./akari > rot13.c; cat rot13.c: " +./akari2 rot13 < akari.c | ./akari > rot13.c; cat rot13.c + + +read -r -n 1 -p "Press any key to run: ./akari2 < akari.c > expanded_output.txt: " +./akari2 < akari.c > expanded_output.txt +read -r -n 1 -p "Press any key to run: ./akari2 rot13 < akari.c > expanded_and_rot13_output.txt: " +./akari2 rot13 < akari.c > expanded_and_rot13_output.txt +read -r -n 1 -p "Press any key to cat expanded_and_rot13_output.txt: " +cat expanded_and_rot13_output.txt diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 56a9a9993..0b4294293 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -3206,6 +3206,11 @@ We're not able to test this. # 2011 +## [2011/akari](2011/akari/akari.c) ([README.md](2011/akari/README.md])) + +Cody added the [try.sh](2011/akari/try.sh) script. + + ## [2011/borsanyi](2011/borsanyi/borsanyi.c) ([README.md](2011/borsanyi/README.md])) Cody, out of an abundance of caution, added a second arg to `main()` as some