Merge pull request #812 from spacewander/git-sed-escape

git-sed: escape special characters for tr
This commit is contained in:
罗泽轩 2019-12-18 11:25:18 +08:00 committed by GitHub
commit bd8fa031cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -70,7 +70,9 @@ all="$search$replacement$flags"
case "$all" in
*/*)
ascii="$(for((i=32;i<=127;i++)) do printf '%b' "\\$(printf '%03o' "$i")"; done)"
sep="$(printf '%s' "$ascii" | tr -d "$all")"
escaped="${all//-/\\-}"
escaped="${escaped//[/\\[}"
sep="$(printf '%s' "$ascii" | tr -d "$escaped")"
sep="$(printf %.1s "$sep")"
if [ "X$sep" = "X" ] ; then
echo 'could not find an unused character for sed separator character'