Binary operator expected

hi
i'm trying to do program that counts the total no of words from files from a directory and all it's subdirectories.ang i get the binary operator expected error at line 7 and line 12.can you please help me with this as quick as possible?

if test -d $1
then
  sum=0
  for name in $1/* 
  do
    if test -f $name
    then
      cuv=$(wc -w $name | awk '{print$1}')
      sum=$(($sum + $cuv))
    fi
    if test -d $name 
    then
      ./dir.sh $name
    fi
  done
  echo $sum
else
  echo $1 is not a directory
fi

Homework? If not, what shell are you using?

no it's not a homework,i'm at college and i have some partial test tomorrow,and i wanted to do some practice,i have ubuntu 9.10 i don't know the version of the shell.