# Copyright (C) 2012 The Meme Factory, Inc. http://www.karlpinc.com/ # Copyright (C) 2010, 2011, Karl O. Pinc # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published # by the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # # Wrapper around xmllint to deliver an exit code on entity error. # # Karl O. Pinc # # Remarks: # Invoke from make with 'sh <./xmllint-wrapper ./xmllint-wrapper'. # This allows the passing of arguments, where Posix source (.) does # not, and keeps us from having to mark this script executable. # # Bugs: # This is a kludge to deal with oddity in xmllint. # # Normally xmllint does not exit with an error when --postvalid is used # and an entity does not exist, but it does send text to stderr. # Go figure. tfile=/tmp/xmllint-wrapper.$$ xmllint --postvalid --noout --xinclude --nonet --noent "$@" 2> $tfile status=$(echo $?) [ -s $tfile ] \ && cat $tfile >&2 \ && rm -f $tfile \ && [ $status = "0" ] \ && exit 1 rm -f $tfile exit $status