I am trying to write a hook that blocks a commit if it has a certain string. I've gotten that working with the following code.
#!/bin/sh
REPOS="$1"
TXN="$2"
COMPARE=`$SVNLOOK diff -t "$TXN" "$REPOS"`
if echo ${COMPARE} | grep -qw "path/to/file/*"; then
if echo ${COMPARE} | egrep "string1"; then
echo "file contains invalid string string1. Unable to commit " 1>&2
exit 1
fi
if echo ${COMPARE} | egrep "string2"; then
echo "file contains invalid string string2. Unable to commit " 1>&2
exit 1
fi
if echo ${COMPARE} | egrep "string3"; then
echo "file contains invalid string string3. Unable to commit" 1>&2
exit 1
fi
fi
Now what I am trying to do is exclude files that end with a "_man.txt". I know you have to use the --exclude=*{_man.txt} but it is not ignoring files and still showing the commit error echo message i have set up. Can anyone see what might I be missing and why?
if echo ${COMPARE} | grep -qw --exclude=\*{_man.txt} "path/to/file/*"; then
if echo ${COMPARE} | egrep "string1"; then
echo "file contains invalid string string1. Unable to commit " 1>&2
exit 1
fi
if echo ${COMPARE} | egrep "string2"; then
echo "file contains invalid string string2. Unable to commit " 1>&2
exit 1
fi
if echo ${COMPARE} | egrep "string3"; then
echo "file contains invalid string string3. Unable to commit" 1>&2
exit 1
fi
fi