diff --git a/2000/dlowe/README.md b/2000/dlowe/README.md index 5e3e4329b..137f664df 100644 --- a/2000/dlowe/README.md +++ b/2000/dlowe/README.md @@ -127,19 +127,19 @@ Floating point exception (core dumped) (or something to that effect) ### Examples: ```sh -$ echo "12 13 14 15 16 + + + + f" | ./dlowe +$ echo '12 13 14 15 16 + + + + f' | ./dlowe 70 -$ echo "12 13 14 15 16 17 + - * / p" | ./dlowe +$ echo '12 13 14 15 16 17 + - * / p' | ./dlowe -0.0515873015873016 -$ echo "+" | ./dlowe +$ echo '+' | ./dlowe stack empty -$ echo "999999999999999 1 + p" | ./dlowe +$ echo '999999999999999 1 + p' | ./dlowe 1e+15 -$ echo "99999999999999 1 + p" | ./dlowe +$ echo '99999999999999 1 + p' | ./dlowe 100000000000000 -$ echo "12.5 9 % 10 * 15 + f" | ./dlowe +$ echo '12.5 9 % 10 * 15 + f' | ./dlowe 50 -$ echo "7 P 6 d P P 8 p" | ./dlowe | tr 876 tpo +$ echo '7 P 6 d P P 8 p' | ./dlowe | tr 876 tpo poot ``` diff --git a/2000/dlowe/try.sh b/2000/dlowe/try.sh new file mode 100755 index 000000000..37c85c701 --- /dev/null +++ b/2000/dlowe/try.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 2000/dlowe +# + +# 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" all >/dev/null || exit 1 + +# clear screen after compilation so that only the entry is shown +clear + +echo "$ echo '13 14 15 16 17 + - * / p' | ./dlowe" 1>&2 +echo '13 14 15 16 17 + - * / p' | ./dlowe + +echo "$ echo '12 13 14 15 16 + + + + f' | ./dlowe" 1>&2 +echo '12 13 14 15 16 + + + + f' | ./dlowe + +echo "$ echo '12 13 14 15 16 17 + - * / p' | ./dlowe" 1>&2 +echo '12 13 14 15 16 17 + - * / p' | ./dlowe + +echo "$ echo '+' | ./dlowe" 1>&2 +echo '+' | ./dlowe + +echo "$ echo '999999999999999 1 + p' | ./dlowe" 1>&2 +echo '999999999999999 1 + p' | ./dlowe + +echo "$ echo '99999999999999 1 + p' | ./dlowe" 1>&2 +echo '99999999999999 1 + p' | ./dlowe + +echo "$ echo '12.5 9 % 10 * 15 + f' | ./dlowe" 1>&2 +echo '12.5 9 % 10 * 15 + f' | ./dlowe diff --git a/bugs.md b/bugs.md index c70d3f949..d68c765e7 100644 --- a/bugs.md +++ b/bugs.md @@ -1565,13 +1565,6 @@ echo "7 P 6 d P P 8 p" | ./dlowe | tr 876 tpo ``` which should print out `poot` but it doesn't, not in linux and not in macOS. -This might in part be because `./dlowe` will show not a number with `876` but -rather - -```sh -$ echo "7 P 6 d P P 8 p" | ./dlowe -7668 -``` In linux it doesn't crash but it doesn't print anything out either. @@ -1579,6 +1572,54 @@ In macOS it crashes; it might appear to not crash in macOS but this is because of the pipeline. If you remove the `| tr 876 tpo` part of the command you will see that it does indeed crash! +The reason for this not working is really strange. + +```sh +$ echo "7 P 6 d P P 8 p" | ./dlowe +7668 +$ echo "7 P 6 d P P 8 p" | ./dlowe | grep 7 +$ +``` + +Why? Is it writing to stdout? Let's try some other things: + +```sh +$ echo 7668 | tr 876 tpo +poot +``` + +Okay so we know that it SHOULD work. But we also know something funny is going on with stdout and the entry. Another experiment: + +```sh +$ echo "7 P 6 d P P 8 p" | ./dlowe 1>&2 | grep 7 +7668 +``` + +Okay so now it sees it, `grep`. But watch! + +```sh +$ echo "7 P 6 d P P 8 p" | ./dlowe 2>foo 1>&1 +7668 +$ cat foo + +``` + +.. so at this hour it does appear to be writing to stdout but yet somehow it doesn't? But watch: + +```sh +$ echo "7 P 6 d P P 8 p" | ./dlowe 1>foo 1>&1 +$ cat foo +$ +``` + +Well this explains why the `tr` does not transliterate it to `poot` but why is +this happening? Why can't it be redirected to another file even? + +If it could be figured out why it's not writing to stdout and yet at the same +time is writing to stdout one bug could be fixed. Maybe it's the perl messing +with things but we don't know. + + Other commands do work, however, and give the appropriate output, such as: ```sh diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 447135445..c21981d26 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -2255,6 +2255,8 @@ He also added the [try.sh](2000/dhyang/try.sh) script. `PL_na` was once `na`. He notes that this entry crashes under macOS but it works under Linux after this change. +Cody also added the [try.sh](2000/dlowe/try.sh) script. + ## [2000/jarijyrki](2000/jarijyrki/jarijyrki.c) ([README.md](2000/jarijyrki/README.md]))