Skip to content
Browse files

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.
  • Loading branch information...
1 parent 144b89b commit 10a7cfee014154e21a235e439c2b6002b833d6b6 @rupa committed Aug 9, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 z.sh
View
2 z.sh
@@ -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

0 comments on commit 10a7cfe

Please sign in to comment.
Something went wrong with that request. Please try again.