adapting to changing names in gffs.
[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)
6 for ((i=0 ; i < ${#codefile_list[@]}; i++)); do
7   if [ ! -z "$phrases" ]; then
8     phrases="$phrases -o"
9   fi
10   phrases="$phrases -iname *${codefile_list[i]}"
11 done
12 #echo phrases is now $phrases
13
14 while true; do
15   export NAME_LIST_TEMP_FILE="$(mktemp "$TMP/zz_code_count.XXXXXX")"
16
17   dir="$1"; shift
18
19   if [ -z "$dir" ]; then
20     break;
21   fi
22
23 #echo dir is $dir
24
25 #set -o xtrace
26 ##hmmm: how to turn off tracing thing?
27
28   find "$dir" -type f $phrases >$NAME_LIST_TEMP_FILE
29
30 #echo ====================================================
31 #echo file holds these matches:
32 #cat $NAME_LIST_TEMP_FILE
33 #echo ====================================================
34
35   while read line; do
36 #echo line is $line
37     count=$(grep -h -v -c "^[ ]*$" $line)
38     TOTALS=$(($TOTALS + $count))
39 #echo total is $TOTALS now
40   done < "$NAME_LIST_TEMP_FILE"
41   
42   rm $NAME_LIST_TEMP_FILE
43
44 done
45
46 echo "total lines of code=$TOTALS"
47