proving git release script isn't busted
[feisty_meow.git] / scripts / buildor / buildor_count_code.sh
1 #!/bin/bash
2
3 TOTALS=0
4
5 codefile_list=(.c .cpp .h .java .pl .py .sh .wsdl .gwsdl .xml .properties .config .configuration .txt makefile\* )
6
7 for ((i=0 ; i < ${#codefile_list[@]}; i++)); do
8   if [ ! -z "$phrases" ]; then
9     phrases="$phrases -o"
10   fi
11   phrases="$phrases -iname \*${codefile_list[i]}"
12 done
13 #echo phrases is now $phrases
14
15 while true; do
16   export NAME_LIST_TEMP_FILE="$(mktemp "$TMP/zz_code_count.XXXXXX")"
17
18   dir="$1"; shift
19   if [ -z "$dir" ]; then
20     rm $NAME_LIST_TEMP_FILE
21
22     break;
23   fi
24 #echo dir is $dir
25
26   # for some reason we had to add an eval in front to get this
27   # working after escaping the asterisk (so as not to include
28   # local files that matched the patterns).
29   eval find "$dir" -type f $phrases >$NAME_LIST_TEMP_FILE
30
31 #echo ====================================================
32 #echo file $NAME_LIST_TEMP_FILE holds these matches:
33 #cat $NAME_LIST_TEMP_FILE
34 #echo ====================================================
35
36   while read input_text; do
37 #echo input_text is $input_text
38     count=$(grep -h -v -c "^[ ]*$" $input_text)
39     TOTALS=$(($TOTALS + $count))
40 #echo total is $TOTALS now
41   done < "$NAME_LIST_TEMP_FILE"
42   
43   rm $NAME_LIST_TEMP_FILE
44
45 done
46
47 echo "total lines of code=$TOTALS"
48