X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=roguelike;fp=roguelike;h=2143f05623a0c98136634c7475aaa5c565d7a707;hb=dd9d65ee727ac7e95801da0f8b5bae7009811802;hp=0000000000000000000000000000000000000000;hpb=c3d87a1dee96775443fdf73c53e1350af7ca5fc2;p=plomrogue diff --git a/roguelike b/roguelike new file mode 100755 index 0000000..2143f05 --- /dev/null +++ b/roguelike @@ -0,0 +1,30 @@ +#!/bin/sh + +# This is only to ensure I write no unintentional bashisms. +set -o posix + +# Abort the script on error. +set -e + +# Use the shell script's arguments to the server's arguments. +./roguelike-server $@ & + +# Give server some time to start up and exit on error. +sleep 0.01 + +# The client should not start if the server is not running. (If the server was +# running in the foreround, any error exit of it so far would be caught by "set +# -e" above. But "set -e" is blind to error codes generated in the background.) +kill -0 $! 2> /dev/null + +# Give server some time (max. 10 seconds) to generate its out file. +i=0 +while [ ! -e server/out ] && [ $i -le 10000 ] +do + sleep 0.01 + i=`expr $i + 1` +done +kill -0 $! 2> /dev/null + +# Only start the interface when everything else went well. +./roguelike-client