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."
16 openttd
"$@" 2> "$TMPFILE"
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 -
24 xmessage
"$CODEMSG No error messages were produced."