5 codefile_list=(.c .cpp .h .java .pl .py .sh .wsdl .gwsdl .xml .properties .config .configuration .txt makefile\* )
7 for ((i=0 ; i < ${#codefile_list[@]}; i++)); do
8 if [ ! -z "$phrases" ]; then
11 phrases="$phrases -iname \*${codefile_list[i]}"
13 #echo phrases is now $phrases
16 export NAME_LIST_TEMP_FILE="$(mktemp "$TMP/zz_code_count.XXXXXX")"
19 if [ -z "$dir" ]; then
24 # for some reason we had to add an eval in front to get this
25 # working after escaping the asterisk (so as not to include
26 # local files that matched the patterns).
27 eval find "$dir" -type f $phrases >$NAME_LIST_TEMP_FILE
29 #echo ====================================================
30 #echo file $NAME_LIST_TEMP_FILE holds these matches:
31 #cat $NAME_LIST_TEMP_FILE
32 #echo ====================================================
34 while read input_text; do
35 #echo input_text is $input_text
36 count=$(grep -h -v -c "^[ ]*$" $input_text)
37 TOTALS=$(($TOTALS + $count))
38 #echo total is $TOTALS now
39 done < "$NAME_LIST_TEMP_FILE"
41 rm $NAME_LIST_TEMP_FILE
45 echo "total lines of code=$TOTALS"