]> git.plutz.net Git - serve0/commitdiff
improved regex search
authorPaul Hänsch <paul@plutz.net>
Wed, 18 Jul 2018 06:42:11 +0000 (08:42 +0200)
committerPaul Hänsch <paul@plutz.net>
Wed, 18 Jul 2018 06:42:11 +0000 (08:42 +0200)
list.sh

diff --git a/list.sh b/list.sh
index e8b7075f1f889ac3c4527dab07d9e475b4d005d9..a2dcd5549e56599a416c670d93fd1c9bb94a61a3 100644 (file)
--- a/list.sh
+++ b/list.sh
@@ -77,9 +77,12 @@ list_filemeta(){
   | if [ "$FILTER" ]; then
     sed -nr "$list_fex"
   elif [ "${SEARCH#!}" != "${SEARCH}" ]; then
-    grep -aviE "$(STRING "${SEARCH#!}" |sed -r 's;((^|[^\\])(\\\\)*)\+;\1\\+;g;')"
+    grep -aviE "$(STRING "${SEARCH#!}" |sed -r ':x s;((^|[^\\])(\\\\)*)\+;\1\\+;g; tx;')"
   else
-    grep -aiE "$(STRING "${SEARCH}" |sed -r 's;((^|[^\\])(\\\\)*)\+;\1\\+;g;')"
+    grep -aiE "$(STRING "${SEARCH}" \
+                 | sed -r ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
+                            s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
+                            s; ;\\+;g;')"
   fi |cut -f6 | UNSTRING \
   | while read -r fn; do
     printf '%s\n' "${base}/${fn%${CR}}"