There appears to be a bug where the program blocks. In one case another command makes it work but the judges remarks suggest one way and it does not. The other command does not seem to work at all, even if used like the workaround with the first one. Updated make clobber to remove foo.ps. Updated .gitignore.
35 lines
842 B
Bash
Executable File
35 lines
842 B
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# try.sh - demonstrate IOCCC entry 1995/leo
|
|
#
|
|
|
|
# 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
|
|
|
|
|
|
# try finding gs
|
|
GS="$(type -P gs)"
|
|
|
|
rm -f foo.ps
|
|
read -r -n 1 -p "Press any key to run: ./leo 1 | cat - > foo.ps: "
|
|
echo "" | ./leo 1 | cat - > foo.ps
|
|
echo 1>&2
|
|
# if they have gs open foo.ps with it
|
|
if [[ -n "$GS" ]]; then
|
|
read -r -n 1 -p "Press any key to run: $GS foo.ps: "
|
|
echo 1>&2
|
|
"$GS" foo.ps
|
|
else
|
|
echo "Now send foo.ps to your local postscript printer or open it in an appropriate" 1>&2
|
|
echo "application (e.g. GIMP)." 1>&2
|
|
fi
|