Created
October 9, 2012 08:01
-
-
Save Zitrax/3857270 to your computer and use it in GitHub Desktop.
Find unused perl functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Note this requires git compiled with USE_LIBPCRE | |
# to be able to use -P to git grep. | |
# And currently for some reason the regexp causes a segmentation fault | |
# when searching for some functions. | |
NCORES=`grep -c ^processor /proc/cpuinfo` | |
ack-grep -h --output='$1' '^\s*sub\s+(\w+)\b' . \ | |
| sort -u \ | |
| xargs -n 1 -P $NCORES -I '{}' sh -c "git grep -c -w -F -P '{}(?=([^\"]*\"[^\"]*\")*[^\"]*$)' \ | |
| awk -F: '{t+=\$2} END{if(t<2) print \"{}\"}'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment