/ doc /
/doc/xmllint-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 xmllint to deliver an exit code on entity error.
20 #
21 # Karl O. Pinc <kop@meme.com>
22 #
23 # Bugs:
24 # This is a kludge to deal with oddity in xmllint.
25 #
26 # Normally xmllint does not exit with an error when --postvalid is used
27 # and an entity does not exist, but it does send text to stderr.
28 # Go figure.
29
30 tfile=/tmp/xmllint-wrapper.$$
31
32 # (It's _so_ wrong to put this path here.)
33 #xmllint --postvalid --noout --xinclude --nonet --noent -relaxng /usr/share/xml/docbook/schema/rng/5.0/docbook.rng "$@" 2> $tfile
34 xmllint --postvalid --noout --xinclude --nonet --noent "$@" 2> $tfile
35 status=$(echo $?)
36
37 [ -s $tfile ] \
38 && cat $tfile >&2 \
39 && rm -f $tfile \
40 && [ $status = "0" ] \
41 && exit 1
42
43 rm -f $tfile
44 exit $status