#!/bin/sh
# Strip whitespace out of files
# 2006 William Jon McCann <mccann@jhu.edu>

CMD=git-stripspace

if test "x$1" = "x" -o  "x$1" = "x-h" -o "x$1" = "x--help"; then
    echo "usage: $0 [file] ..."
    exit 1
fi

FILES="$@"
for FILE in $FILES; do

    if [ ! -r ${FILE} ]; then
        echo "File not found: ${FILE}"
        continue
    fi

    outfile="${FILE}.tmp"

    echo "Stripping: ${FILE}"
    ${CMD} < ${FILE} > ${outfile}
    if [ $? -ne 0 ]; then
        exit 1
    fi

    mv ${outfile} ${FILE}

done

exit 0
