mirror of
https://github.com/tj/git-extras.git
synced 2026-09-15 09:56:19 -04:00
git-sed: escape special characters for tr
Some special patterns like `n-l`, `[:alpha:]` need to be escaped to avoid confusing tr.
This commit is contained in:
parent
69e96cba95
commit
4d5b53aea2
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Reference in a new issue