My command: git show --pretty="format:" --name-only
returns list of files.
Then I use xargs to run a shell script on those files:
git show --pretty="format:" --name-only | xargs -i phpmd $dir/'{}' text codesize,unusedcode,naming
However, I'd like to run that xargs command only on files with .php
extension. How to filter the unwanted files?
If your filenames may contain space or quotes, you should use GNU Parallel http://www.gnu.org/software/parallel/ instead of xargs as xargs can lead to nasty surprises because of the separator problem http://en.wikipedia.org/wiki/Xargs#The_separator_problem:
GNU Watch the intro video for GNU Parallel to learn more: http://www.youtube.com/watch?v=OpaiGYxkSuQ