From 7fe57a582994f9e369aa14cfcdf6ade4860d1623 Mon Sep 17 00:00:00 2001 From: rupa Date: Tue, 7 Feb 2012 11:52:47 -0500 Subject: [PATCH] deal with weird dirs a bit better * quote tab expansions * commented out code for thinking about dirs that break awk regex. Haven't quite figured out a good approach. --- z.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/z.sh b/z.sh index 337a2d0..d30efcc 100755 --- a/z.sh +++ b/z.sh @@ -92,7 +92,7 @@ _z() { } else { for( i in fnd ) $1 !~ fnd[i] && $1 = "" } - if( $1 ) print $1 + if( $1 ) print "\"" $1 "\"" } ' "$datafile" 2>/dev/null @@ -154,6 +154,10 @@ _z() { if( matches[i] && (!short || length(i) < length(short)) ) short = i } if( short == "/" ) return + + # escape regex chars in right hand side + #gsub(/[\(\[\|]/, "\\\&", short) + # shortest match must be common to each match for( i in matches ) if( matches[i] && i !~ short ) return return short