diff options
author | Tommy Reynolds <Tommy.Reynolds@MegaCoder.com> | 2005-06-27 19:49:20 +0000 |
---|---|---|
committer | Tommy Reynolds <Tommy.Reynolds@MegaCoder.com> | 2005-06-27 19:49:20 +0000 |
commit | 91bdd805a5d90b0385e1fdc1d5baeba3afae3362 (patch) | |
tree | 403ab8fe369860b8369656d14b176e2f1fca9ec6 /bin/tidy-bowl | |
parent | 3c33127fa82c086ff1fc597abad32f2a9c33be82 (diff) | |
download | fedora-doc-utils-91bdd805a5d90b0385e1fdc1d5baeba3afae3362.tar.gz fedora-doc-utils-91bdd805a5d90b0385e1fdc1d5baeba3afae3362.tar.xz fedora-doc-utils-91bdd805a5d90b0385e1fdc1d5baeba3afae3362.zip |
Make the XML format normalization tools available to the client side.
Diffstat (limited to 'bin/tidy-bowl')
-rwxr-xr-x | bin/tidy-bowl | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/bin/tidy-bowl b/bin/tidy-bowl new file mode 100755 index 0000000..aac11a2 --- /dev/null +++ b/bin/tidy-bowl @@ -0,0 +1,63 @@ +#!/bin/sh +######################################################################## +# +# This script is invoked by "commitinfo" just after the incoming file has +# been uploaded to the server. It gets passed these arguments: +# +# tidy-bowl file ... +# +# If we approve of the commit for EVERY file in the list, then we return +# a zero (0). Any non-zero return aborts the commit, so we must be very +# careful here. +# +# AFAIK, the $PWD is the temporary file where the incoming "file" is located, +# but that needs to be verified. +# +# For every "file" that ends with ".xml", we will attempt to normalize the +# formatting by using tidy(1) to prettyprint it. We must overwrite "file" so +# that the rest of CVS knows where to find the file. +# +# There doesn't seem to be any way to return error messages, so we'll just bang +# them out to "/var/log/messages". +# +######################################################################## +# exit 0 # Early exit while frobbing around +######################################################################## +# All ancillary files should be in the same directory as this script +ME=`/bin/basename $0` +PREFIX=`/usr/bin/dirname $0` +######################################################################## +USAGE="Usage: ${ME} [-T tool] [-t tool-args] file..." +NORMTOOL=${PREFIX}/xmlformat +NORMARGS="-i -v -f ${PREFIX}/xmlformat-fdp.conf" +while getopts T:t: c +do + case "${c}" in + T) NORMTOOL="${OPTARG}";; + t) NORMARGS="${OPTARG}";; + *) /bin/echo "${USAGE}" >&2; exit 1;; + esac +done +shift `/usr/bin/expr "${OPTIND}" - 1` +######################################################################## +for fn in $@ +do + case "${fn}" in + *.[Xx][Mm][Ll] ) + # Make sure we can find the input file + if [ ! -f "${fn}" ]; then + /bin/echo $0 "Cannot find '${fn}'" + exit 1 + fi + # Try to clean it up + ${NORMTOOL} ${NORMARGS} "${fn}" + if [ $? -ne 0 ]; then + /bin/echo $0 "File '${fn}' unclean." + exit 1 + fi + ;; + * ) + ;; + esac +done +exit 0 |