From 10a7cfee014154e21a235e439c2b6002b833d6b6 Mon Sep 17 00:00:00 2001 From: rupa Date: Thu, 9 Aug 2012 14:11:31 -0400 Subject: [PATCH] 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. --- z.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/z.sh b/z.sh index 2a864fc..848e408 100755 --- a/z.sh +++ b/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