1#!/bin/bash 2 3if [ "$1" == "-h" ] 4then 5 cat <<- EOH 6 Usage: $0 [-p] [folder] 7 -p option prints out unused strings, otherwise a total count is printed 8 folder option causes only that app folder to be scanned, default is to scan all folders onder apps/ 9 EOH 10 exit 11fi 12 13showall=no 14if [ "$1" == "-p" ] 15then 16 showall=yes 17 shift 18fi 19 20apps=$1 21if [ "$apps" == "" ] 22then 23 apps=$ANDROID_BUILD_TOP/packages/apps/* 24fi 25 26for app in $apps 27do 28 if [ -d $app/res ] 29 then 30 pushd $app > /dev/null 31 # Two sed's were needed because the | operator is not supported on the mac 32 for i in $(grep -Rs "\(string\|plurals\) name=" res | sed 's/.*string name=\"//' | sed 's/.*plurals name=\"//'|sed 's/".*$//'|sort -u) 33 do 34 echo $i $(grep -Rws R.plurals.$i\\\|R.string.$i\\\|@string/$i .|wc -l) 35 done | grep ' 0$' | { 36 if [ "$showall" == "yes" ] 37 then 38 echo $app 39 cat 40 else 41 count=$(wc -l) 42 if [ "$count" != "0" ] 43 then 44 echo $app: $count unused strings 45 fi 46 fi 47 } 48 popd $app > /dev/null 49 fi 50done 51