Add try.sh to 1989/fubar
This commit is contained in:
1 parent
92a6682216
commit
231530d890
4 files changed
+39
-3
No files matched your search
+2
-1
@@ -38,7 +38,8 @@ include ../../var.mk
|
||||
|
||||
# Common C compiler warnings to silence
|
||||
#
|
||||
CSILENCE= -Wno-implicit-function-declaration -Wno-incompatible-library-redeclaration -Wno-implicit-int
|
||||
CSILENCE= -Wno-implicit-function-declaration -Wno-incompatible-library-redeclaration -Wno-implicit-int \
|
||||
-Wno-deprecated-non-prototype
|
||||
|
||||
# Common C compiler warning flags
|
||||
#
|
||||
|
||||
@@ -26,14 +26,17 @@ For more detailed information see [1989 fubar in bugs.md](/bugs.md#1989-fubar).
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
./fubar 2
|
||||
./try.sh # run on 1 - 7
|
||||
|
||||
./fubar.sh 2 # run via script
|
||||
./fubar 2 # run directly
|
||||
```
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
Run this with a single digit argument (or wait a long time and risk an infinite
|
||||
loop as described above).
|
||||
loop as described in the [bugs.md](/bugs.md#1989-fubar) file).
|
||||
|
||||
The blank line at the beginning of the source is mandatory.
|
||||
Do you know why?
|
||||
|
||||
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 1989/fubar
|
||||
#
|
||||
|
||||
# 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
|
||||
|
||||
fubar()
|
||||
{
|
||||
if [[ "$#" -ne 1 ]]; then
|
||||
echo "$0: expected 1 arg, got: $#" 1>&2
|
||||
else
|
||||
read -r -n 1 -p "Press any key to run: ./fubar.sh $1: "
|
||||
echo 1>&2
|
||||
./fubar.sh "$1"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
for i in $(seq 1 7); do fubar "$i" ; done
|
||||
@@ -761,6 +761,8 @@ not strictly necessary but nonetheless more correct, even if not warned against.
|
||||
Cody also 'modernised' the script to use `bash` and fixed for ShellCheck. The
|
||||
`if [ .. ]` was changed in the C code as well as the script.
|
||||
|
||||
Cody also added the [try.sh](/1989/fubar/try.sh) script.
|
||||
|
||||
|
||||
## <a name="1989_jar.1"></a>[1989/jar.1](/1989/jar.1/jar.1.c) ([README.md](/1989/jar.1/README.md]))
|
||||
|
||||
|
||||
Reference in new issue
Block a user