Fixed readCsv() regex
authorCian Bagshaw <cian@cianb.xyz>
Tue, 6 Jun 2023 00:09:37 +0000 (01:09 +0100)
committerCian Bagshaw <cian@cianb.xyz>
Tue, 6 Jun 2023 00:09:37 +0000 (01:09 +0100)
buseir

diff --git a/buseir b/buseir
index 2e192a2..e72fd24 100755 (executable)
--- a/buseir
+++ b/buseir
@@ -10,7 +10,10 @@ menu() { fzf -m --reverse --height=12; }
 
 readCsv() {
        if [ "$2" = "all" ];
-               then cat "$1"; else grep "[\"^,]$2[\"$,]" "$1"
+               then cat "$1";
+               else echo "$2" | while read -r key
+                       do echo "\(\"\|^\|,\)$key\(\"\|$\|,\)"
+                       done | grep -f - "$1" 
        fi | cut -d, -f "$3" | tr -d \"
 }
 
@@ -36,7 +39,7 @@ stops() {
                all) COL=1-;;   num) COL=2;;    duid) COL=3;;
                pos) COL=4-5;;  *) COL=1;;
        esac
-       readCsv "$CACHE"/stops.csv "$1" "$COL" 
+       readCsv "$CACHE"/stops.csv "$1" "$COL"
 }
 
 printStop() {