Created
June 30, 2021 14:20
-
-
Save bhenderson/cc39407b87714038c4d033ac9e9532e1 to your computer and use it in GitHub Desktop.
perl pie but only act on git files. Optional second parameter can dramatically speed up the replacement.
This file contains 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 | |
set -euo pipefail | |
### | |
# Usage | |
# | |
# git pie <perl-script> [git grep options] | |
script=$1; shift | |
# if no grep options, search for `.` which will return all files. | |
[ $# = 0 ] && set -- . | |
# -z support files with weird characters/spaces | |
# -I don't search binary files | |
git grep --name-only -z -I "$@" | xargs -0 perl -pi -e "$script" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment