correct a bug when escaping regex characters

* "\\&" was just turning characters into literal &s, "\\\&" seems to
  work, at least on this OS/awk version.
* Added ) and ] to escaped characters.
This commit is contained in:
rupa committed 2012-08-09 14:11:31 -04:00
1 parent 144b89b4a4
commit 10a7cfee01
1 file changed
+1 -1
+1 -1
View File
@@ -142,7 +142,7 @@ _z() {
if( short == "/" ) return
# escape regex chars in right hand side
gsub(/[\(\[\|]/, "\\&", short)
gsub(/[\(\)\[\]\|]/, "\\\&", short)
# shortest match must be common to each match
for( i in matches ) if( matches[i] && i !~ short ) return