40 lines
1.2 KiB
Bash
Executable File
40 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# checkCtrlM checks source code for explicit ctrl-M's
|
|
# checks only files with the following extensions: .c, .cxx, .txx, .html, .htm
|
|
# exits with 0, if all commited files pass the test.
|
|
# exits with 1, if any one of the tests fails
|
|
#
|
|
# checkCtrlM can be run as a cvs commitinfo command.
|
|
# The following commitinfo line (without the #) will run the script
|
|
# ALL $CVSROOT/CVSROOT/checkCtrlM
|
|
#
|
|
failed=0
|
|
#
|
|
# skip the first arg, the directory
|
|
shift 1
|
|
|
|
for file in "$@"; do
|
|
#
|
|
# select files with extentions .txx, .cxx, .h, .html, .htm
|
|
match=`echo $file | egrep \[\.\]txx\$\|\[\.\]cxx\$\|\[\.\]h\$\|\[\.\]html\$\|\[\.\]htm\$\|\[\.\]c\$`
|
|
if [ "x$match" != "x" ] ; then
|
|
count=`grep -n
|
|
\$ /dev/null $file|wc -c`
|
|
results=`expr $count \| 0`
|
|
if [ "$results" != "0" ]; then
|
|
echo "=========================================================="
|
|
if [ $results -lt 200 ]; then
|
|
grep -n
|
|
\$ /dev/null $file
|
|
fi
|
|
echo ""
|
|
echo "$file has ^M's. They must be removed before you can commit."
|
|
echo "The problem count was $results"
|
|
echo "=========================================================="
|
|
failed=1
|
|
fi
|
|
fi
|
|
done
|
|
exit $failed
|