blob: 3c35f7d365056d1284c86143ea9024e346418be6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#!/bin/sh
# This is a wrapper script that checks openttd's exit status and
# displays its stderr output
# Get a file to capture stderr to
TMPFILE=`mktemp --tmpdir openttd.errout.XXXXXXXXX`
if [ ! -w "$TMPFILE" ]; then
xmessage "Could not create temporary file for error messages. Not starting OpenTTD."
exit 1;
fi
# Capture stderr
openttd "$@" 2> "$TMPFILE"
ERRCODE=$?
if [ "$ERRCODE" -ne 0 ]; then
CODEMSG="OpenTTD returned with error code $ERRCODE."
if [ -s "$TMPFILE" ]; then
MESSAGE="$CODEMSG The following error messages were produced:\n\n"
printf "$MESSAGE" | cat - "$TMPFILE" | fold -s | xmessage -file -
else
xmessage "$CODEMSG No error messages were produced."
fi
fi
rm -f "$TMPFILE"
|