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
20 rm $NAME_LIST_TEMP_FILE
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
31 #echo ====================================================
32 #echo file $NAME_LIST_TEMP_FILE holds these matches:
33 #cat $NAME_LIST_TEMP_FILE
34 #echo ====================================================
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"
43 rm $NAME_LIST_TEMP_FILE
47 echo "total lines of code=$TOTALS"