(svn r27967) -Update from Eints:
[openttd.git] / os / debian / openttd-wrapper
blob6f85f00b0601526780169b320264a0a3664f51a6
1 #!/bin/sh
2 # This is a wrapper script that checks openttd's exit status and
3 # displays its stderr output
5 # Get a file to capture stderr to. Use the deprecated -t option, so this
6 # works on the old mktemp from the mktemp package (which has been
7 # replaced by the version from the coreutils package).
8 TMPFILE=`mktemp -t openttd.errout.XXXXXXXXX`
10 if [ ! -w "$TMPFILE" ]; then
11 xmessage "Could not create temporary file for error messages. Not starting OpenTTD."
12 exit 1;
15 # Capture stderr
16 openttd "$@" 2> "$TMPFILE"
17 ERRCODE=$?
18 if [ "$ERRCODE" -ne 0 ]; then
19 CODEMSG="OpenTTD returned with error code $ERRCODE."
20 if [ -s "$TMPFILE" ]; then
21 MESSAGE="$CODEMSG The following error messages were produced:\n\n"
22 printf "$MESSAGE" | cat - "$TMPFILE" | fold -s | xmessage -file -
23 else
24 xmessage "$CODEMSG No error messages were produced."
28 rm -f "$TMPFILE"