Merge pull request #1826 from xexyl/laman84-try

Add 1984/laman/try.sh
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2024-01-05 09:39:10 -08:00
commit bd2fe949f5
3 files changed
+65 -2

No files matched your search

+2
View File
@@ -18,6 +18,8 @@ The program accepts ONE POSITIVE number. Seeing is believing, so try things
like:
```sh
./try.sh
./laman 4
./laman 9
./laman 16
+60
View File
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1984/laman
#
# 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
run()
{
if [[ "$#" -ne 1 ]]; then
echo "$0: expected 1 arg, got: $#" 1>&2
return
fi
read -r -n 1 -p "Press any key to run: ./laman $1: "
echo 1>&2
./laman "$1"
echo 1>&2
}
run_twice()
{
if [[ "$#" -ne 1 ]]; then
echo "$0: expected 1 arg, got: $#" 1>&2
return
fi
read -r -n 1 -p "Press any key to run: ./laman $1; ./laman $1: "
echo 1>&2
./laman "$1"; ./laman "$1"
echo 1>&2
}
run 4
run 9
run 16
run_twice 4
run_twice 9
run_twice 16
read -r -n 1 -p "Press any key to run: ./laman 4; ./laman 9; ./laman 16: "
echo 1>&2
./laman 4; ./laman 9; ./laman 16
echo 1>&2
read -r -n 1 -p "Press any key to run: ./laman 4; ./laman 8; ./laman 16; ./laman 32; ./laman 64: "
echo 1>&2
./laman 4; ./laman 8; ./laman 16; ./laman 32; ./laman 64
echo 1>&2
+3 -2
View File
@@ -121,9 +121,10 @@ cd 1984/decot ; make diff_orig_prog
## <a name="1984_laman"></a>[1984/laman](/1984/laman/laman.c) ([README.md](/1984/laman/README.md]))
[Cody](#cody) fixed this to not crash when no arg is specified. Note that if the arg is
not a positive number it will not do anything useful or anything at all.
[Cody](#cody) added the [try.sh](1984/laman/try.sh) script.
Cody also fixed this to not crash when no arg is specified. Note that if the arg
is not a positive number it will not do anything useful or anything at all.
This was fixed on 30 October 2023 after the bug status was changed from INABIAF
(it's not a bug it's a feature) to bug.