aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--%HOME%/.bash_utils/git.sh20
1 files changed, 18 insertions, 2 deletions
diff --git a/%HOME%/.bash_utils/git.sh b/%HOME%/.bash_utils/git.sh
index 3542ed6..c7a2cbd 100644
--- a/%HOME%/.bash_utils/git.sh
+++ b/%HOME%/.bash_utils/git.sh
@@ -81,7 +81,15 @@ git_replace() (
readonly str="$1"
readonly sub="$2"
- git grep --files-with-matches -- "$str" | xargs sed -i "s/$str/$sub/g"
+ local path
+ local -a paths=()
+
+ git grep -z --files-with-matches -- "$str" |
+ while IFS= read -d '' -r path; do
+ paths+=("$path")
+ done
+
+ file_replace "$str" "$sub" ${paths[@]+"${paths[@]}"}
)
git_replace_word() (
@@ -95,5 +103,13 @@ git_replace_word() (
readonly str="$1"
readonly sub="$2"
- git grep --files-with-matches --word-regexp -- "$str" | xargs sed -i "s/\b$str\b/$sub/g"
+ local path
+ local -a paths=()
+
+ git grep -z --files-with-matches -- "$str" |
+ while IFS= read -d '' -r path; do
+ paths+=("$path")
+ done
+
+ file_replace_word "$str" "$sub" ${paths[@]+"${paths[@]}"}
)