Add 2001/coupard/try.sh
This commit is contained in:
1 parent
73df990d9f
commit
c6f12a2a23
3 files changed
+46
-16
No files matched your search
+1
-12
@@ -14,19 +14,8 @@ make
|
||||
|
||||
## Try:
|
||||
|
||||
If you have access to `/dev/audio` or `/dev/sound/dsp`:
|
||||
|
||||
```sh
|
||||
./coupard > /dev/audio
|
||||
./coupard > /dev/sound/dsp
|
||||
```
|
||||
|
||||
If you do not, first install [sox](https://en.wikipedia.org/wiki/SoX). If you
|
||||
use macOS you might install it from [MacPorts](https://www.macports.org) or
|
||||
[Homebrew](https://brew.sh). Then you can try:
|
||||
|
||||
```sh
|
||||
./coupard | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
|
||||
Executable
+36
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 2001/coupard
|
||||
#
|
||||
|
||||
# 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.
|
||||
[[ -z "$CC" ]] && CC="cc"
|
||||
|
||||
# in this case we won't fail if we can't compile the code because we can still
|
||||
# run the supplementary program.
|
||||
make CC="$CC" everything >/dev/null
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
# hopefully sox(1) is installed but we check for it just in case that it's not
|
||||
SOX="$(type -P sox)"
|
||||
AUDIO="/dev/audio"
|
||||
DSP="/dev/sound/dsp"
|
||||
|
||||
if [[ -n "$SOX" ]]; then
|
||||
echo "$ ./coupard | $SOX -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio" 1>&2
|
||||
read -r -n 1 -p "Press any key to continue: "
|
||||
echo 1>&2
|
||||
./coupard | "$SOX" -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio
|
||||
echo 1>&2
|
||||
elif [[ -S "$AUDIO" ]]; then
|
||||
./coupard > "$AUDIO"
|
||||
elif [[ -S "$DSP" ]]; then
|
||||
./coupard > "$DSP"
|
||||
else
|
||||
echo "SoX not installed. Please install it and try again." 1>&2
|
||||
echo "Tip: see https://github.com/ioccc-src/temp-test-ioccc/blob/master/faq.md#sox." 1>&2
|
||||
fi
|
||||
+9
-4
@@ -2808,14 +2808,19 @@ void e(n,h){
|
||||
|
||||
```
|
||||
|
||||
This was not really worth a thanks per se but it was originally done by adding
|
||||
`int`. The better solution is to disable the warning which is what was done
|
||||
later on to make it more like the original.
|
||||
and for some reason it was being reported as an error. This was not really worth
|
||||
a thanks per se but it was originally done by adding `int`. The better solution
|
||||
is to disable the warning which is what was done later on to make it more like
|
||||
the original.
|
||||
|
||||
Yusuke provided a proper command line for macOS (to do with sound; see his
|
||||
[Yusuke](#yusuke) provided a proper command line for those without `/dev/audio`
|
||||
or `/dev/sound/dsp` (which is most everyone nowadays, it seems, and especially
|
||||
those with macOS) (to do with sound; see his
|
||||
[/2013/endoh3/README.md](/2013/endoh3/README.md) entry where he also refers to
|
||||
sound devices in macOS).
|
||||
|
||||
Cody added the [try.sh](/2001/coupard/try.sh).
|
||||
|
||||
|
||||
## <a name="2001_ctk"></a>[2001/ctk](/2001/ctk/ctk.c) ([README.md](/2001/ctk/README.md]))
|
||||
|
||||
|
||||
Reference in new issue
Block a user