123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- #!/bin/bash
- ERRORS=0
- if [ "$1" = "" ]
- then
- pushd . >/dev/null
- else
- echo Checking $1 ...
- pushd $1 >/dev/null
- fi
- if [ ! -f series ]
- then
- echo no series file found
- popd >/dev/null
- exit 1
- fi
- for i in *
- do
- if [ "$i" != "series" -a "$i" != "status" ]
- then
- j=`echo $i | sed -e 's@[A-Za-z0-9_.+-]@@g'`
- if [ "$j" != "" ]
- then
- echo illiegal character\(s\) \'$j\' in filename \'$i\'
- ERRORS=`expr $ERRORS + 1`
- fi
- j=`echo $i | sed -e 's@\.@\\\.@g'`
- COUNT=`grep ^$j$ series | wc | sed -e 's@^\s*@@g' -e 's@ .*$@@g'`
- if [ "$COUNT" != "1" ]
- then
- ERRORS=`expr $ERRORS + 1`
- echo $i appears $COUNT times in series
- fi
- # NUM=3
- NUM=`grep -n '^diff' $i | head -1 | sed -e 's@\:.*$@@'`
- if [ "$NUM" = "" ]
- then
- cp $i /tmp/cs$$
- else
- NUM=`expr $NUM - 1`
- head -$NUM $i > /tmp/cs$$
- fi
- if file /tmp/cs$$ | grep 'ISO-' >/dev/null
- then
- ERRORS=`expr $ERRORS + 1`
- echo non-ascii characters in $i
- fi
- rm /tmp/cs$$
- if head -1 $i | grep -v '^# HG changeset patch$' >/dev/null
- then
- ERRORS=`expr $ERRORS + 1`
- echo bad hg header in $i
- fi
- if ! head -3 $i | grep '^# User .*[@<].*[>A-Za-z0-9]$' >/dev/null
- then
- ERRORS=`expr $ERRORS + 1`
- echo bad hg header in $i
- fi
- if ! head -4 $i | grep '# Date .*[0-9]$' >/dev/null
- then
- ERRORS=`expr $ERRORS + 1`
- echo bad hg header in $i
- fi
- fi
- done
- for i in `cat series`
- do
- if [ ! -f $i ]
- then
- echo File $i in series does not exist.
- ERRORS=`expr $ERRORS + 1`
- echo $i
- fi
- done
- popd >/dev/null
- if [ "$ERRORS" = "0" ]
- then
- echo no errors detected
- exit 0
- else
- if [ "$ERRORS" = "1" ]
- then
- echo 1 error detected
- else
- echo $ERRORS errors detected
- fi
- fi
- exit 1
|