From e4a024b329cdd02e6e82ed161534d217415e8abb Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Fri, 13 Oct 2023 04:20:08 -0700 Subject: [PATCH] Improvements and fixes to 2013/dlowe The README.md format was messed up (extraneous and erroneous '```'s) due to the nightmare (or perhaps daymare :-) ) of the many merging conflicts of yesterday which required repeatedly resolving conflicts in GitHub. I also renamed 'slen.sh' to 'sflen.sh' as it shows the sparkle OF the length of all the files rather than a sparkle length. References to slen.sh have been changed to sflen.sh instead. The demo.sh script and the sflen.sh script now run: make all || exit 1 before proceeding. It does not do make clobber before because this only clutters the output and is unnecessary if everything is already compiled. Oh and just for those who wonder if daymare is or is not really a word: it is but I redefined it; literally it refers to a frightening hallucinatory experience whilst awake (though perhaps GitHub was hallucinating :-) that there were conflicts (well there were but there shouldn't have been)). --- 2013/dlowe/README.md | 24 +++++++----------------- 2013/dlowe/demo.sh | 7 +++---- 2013/dlowe/{slen.sh => sflen.sh} | 2 ++ thanks-for-fixes.md | 11 ++++++----- 4 files changed, 18 insertions(+), 26 deletions(-) rename 2013/dlowe/{slen.sh => sflen.sh} (72%) diff --git a/2013/dlowe/README.md b/2013/dlowe/README.md index 4a0c3b867..b06d81b1c 100644 --- a/2013/dlowe/README.md +++ b/2013/dlowe/README.md @@ -24,17 +24,9 @@ make ./dlowe 16 32 64 128 ./dlowe 16 32 64 128 256 ./dlowe 16 32 64 128 256 512 - -echo "sparkline of file sizes: $(wc -c * | awk '{print $1}' | xargs ./dlowe)" # or ./slen.sh - ./dlowe 0 -echo "sparkline of file sizes: $(wc -c * | awk '{print $1}' | xargs ./dlowe)" # or ./slen.sh -``` - -./dlowe 0 - -echo "sparkline of file sizes: $(wc -c * | awk '{print $1}' | xargs ./dlowe)" # or ./slen.sh +echo "sparkline of file sizes: $(wc -c * | awk '{print $1}' | xargs ./dlowe)" # or ./sflen.sh ``` Alternatively, for the lazy or those short on time, try: @@ -51,10 +43,9 @@ echo 'IOCCC 2013' > ioccc.txt rm -f ioccc.txt ``` - ? -To make it simpler to see try showing just the last two lines: +To make it simpler to see try showing just the different line like: ```sh ./demo.sh | tail -n 2 > 1.txt @@ -79,8 +70,8 @@ something funny (or will it ? :-) ) and when will it do nothing? We liked how this entry used Unicode, specifically UTF-8, in a somewhat obfuscated way. -Also, why doesn't it crash, and produces a correct output when called with one argument -or when all arguments are equal? +Also, why doesn't it crash but instead produces a correct output when called +with one argument or when all arguments are equal? For extra fun, compile and run [fun.c](fun.c): @@ -106,7 +97,7 @@ and with clang (3.3), we get -2147483648 0 2147483647 ``` -and with Apple clang version 15.0.0 (clang-1500.0.40.1) we get: +and with Apple clang version 15.0.0 (clang-1500.0.40.1) in 2023, we get: ``` 1840985120 -2033041452 35979112 @@ -117,7 +108,6 @@ Which one is correct? :) NOTE: `make all` will compile [fun.c](fun.c) but to provide a different compiler you can do something like: - ```sh make CC=clang fun ``` @@ -140,10 +130,10 @@ $ echo "sparkline of file lengths: $(wc -c * | awk '{print $1}' | xargs ./sparkl sparkline of file sizes: ▁▁▁▃▃▂▁▂▁▁▉ ``` -NOTE: this has been provided in [slen.sh](slen.sh) so you can try: +NOTE: this has been provided in [sflen.sh](sflen.sh) so you can try: ```sh -./slen.sh +./sflen.sh ``` instead. diff --git a/2013/dlowe/demo.sh b/2013/dlowe/demo.sh index daebfe6e6..6bf7ca29a 100755 --- a/2013/dlowe/demo.sh +++ b/2013/dlowe/demo.sh @@ -1,7 +1,6 @@ #!/usr/bin/env bash -make clobber all || exit 1 - +make all || exit 1 echo "$ ./dlowe 0 1 2 3 4 5 6 7" ./dlowe 0 1 2 3 4 5 6 7 echo @@ -17,5 +16,5 @@ echo echo "$ ./dlowe 0" ./dlowe 0 echo -echo "$ ./slen.sh" -./slen.sh +echo "$ ./sflen.sh" +./sflen.sh diff --git a/2013/dlowe/slen.sh b/2013/dlowe/sflen.sh similarity index 72% rename from 2013/dlowe/slen.sh rename to 2013/dlowe/sflen.sh index 83461efb8..8cf09b2ff 100755 --- a/2013/dlowe/slen.sh +++ b/2013/dlowe/sflen.sh @@ -1,3 +1,5 @@ #!/usr/bin/env bash +make all || exit 1 +ln -sf dlowe sparkl echo "sparkline of file lengths: $(wc -c ./* | awk '{print $1}' | xargs ./sparkl)" diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 88c6632a4..20d18581d 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -1641,15 +1641,16 @@ Cody added the source code that we suggested one should compile and run with different compilers as [fun.c](2013/dlowe/fun.c). He modified the Makefile so that running `make all` will compile it, saving you the effort. -He also provided the script [slen.sh](2013/dlowe/slen.sh) which is based on the -author's remarks, giving a script that shows the spark line of the file lengths -(as in `wc -c`), fixing it for shellcheck. These fixes were applied in the -author's remarks as well. +He also provided the script [sflen.sh](2013/dlowe/sflen.sh), fixing it for +shellcheck, which is based on the author's remarks, giving a script that shows +the spark line of the file lengths (as in `wc -c`). These fixes were applied in +the author's remarks as well. Since the author called the program `sparkl` Cody modified the Makefile so that running `make all` will create a symlink to `dlowe` as `sparkl`. Running `make clobber` will delete both and running `make clobber all` will ensure that the -symlink is created. +symlink is created. The `sflen.sh` script also explicitly makes sure to create +the symlink as it uses it, even though it runs `make clobber all`. Cody also added the [demo.sh](2013/dlowe/demo.sh) script to more easily try the program.