/ doc /
/doc/dblatex-wrapper
1 # Copyright (C) 2012 The Meme Factory, Inc. http://www.meme.com/
2 # Copyright (C) 2010, 2011, Karl O. Pinc <kop@meme.com>
3 #
4 # This file is part of Gombe-MI.
5 #
6 # Gombe-MI is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with Gombe-MI. If not, see <http://www.gnu.org/licenses/>.
18 #
19 # Wrapper around dblatex to deliver an exit code on error.
20 #
21 # Karl O. Pinc <kop@meme.com>
22 #
23 # Remarks:
24 # Run with "sh <./dblatex-wrapper dblatex-wrapper" so that it
25 # does not have to be executable and does not have to rely on
26 # a (non-Posix) source (.) which takes arguments.
27 #
28 # Bugs:
29 # This is a kludge to deal with oddity in dblatex.
30 #
31 # Normally dblatex does not exit with an error when, at least,
32 # an olink does not resolve, but it does send text to stderr.
33 # Go figure.
34
35 export tfile=/tmp/dblatex-wrapper.$$
36
37 cleanup() {
38 rm -f $tfile
39 }
40 trap cleanup ALRM HUP INT PIPE PROF TERM USR1 USR2 VTALRM EXIT
41
42 dblatex "$@" >$tfile 2>&1
43
44 status=$(echo $?)
45
46 if [ -s $tfile ] && cat $tfile && [ $status = "0" ] ; then
47 ! grep ^Error: $tfile >/dev/null 2>/dev/null
48 exit
49 fi
50
51 exit $status