From 4f390ce801c739ea87cfcae131855ecbd9161818 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 2 Mar 2020 05:39:21 -0800 Subject: [PATCH 1/3] Use bash regex instead of awk. Signed-off-by: Dan Schaper --- advanced/Scripts/query.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh index a96129e0..73650400 100755 --- a/advanced/Scripts/query.sh +++ b/advanced/Scripts/query.sh @@ -33,15 +33,13 @@ scanList(){ export LC_CTYPE=C # /dev/null forces filename to be printed when only one list has been generated - # shellcheck disable=SC2086 case "${type}" in "exact" ) grep -i -E -l "(^|(?/dev/null;; # Create array of regexps # Iterate through each regexp and check whether it matches the domainQuery # If it does, print the matching regexp and continue looping # Input 1 - regexps | Input 2 - domainQuery - "regex" ) awk 'NR==FNR{regexps[$0];next}{for (r in regexps)if($0 ~ r)print r}' \ - <(echo "${lists}") <(echo "${domain}") 2>/dev/null;; + "regex" ) if [[ "${domain}" =~ ${lists} ]]; then printf "%b\n" "${lists}"; fi;; * ) grep -i "${esc_domain}" ${lists} /dev/null 2>/dev/null;; esac } From 360d0e4e6bfb5c71e078be41d21132422fb20323 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 2 Mar 2020 08:07:10 -0800 Subject: [PATCH 2/3] Loop through array of lists. Signed-off-by: Dan Schaper --- advanced/Scripts/query.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh index 73650400..4dc9429d 100755 --- a/advanced/Scripts/query.sh +++ b/advanced/Scripts/query.sh @@ -35,11 +35,15 @@ scanList(){ # /dev/null forces filename to be printed when only one list has been generated case "${type}" in "exact" ) grep -i -E -l "(^|(?/dev/null;; - # Create array of regexps # Iterate through each regexp and check whether it matches the domainQuery # If it does, print the matching regexp and continue looping # Input 1 - regexps | Input 2 - domainQuery - "regex" ) if [[ "${domain}" =~ ${lists} ]]; then printf "%b\n" "${lists}"; fi;; + "regex" ) + for list in `echo "${lists}"`; do + if [[ "${domain}" =~ ${list} ]]; then + printf "%b\n" "${list}"; + fi + done;; * ) grep -i "${esc_domain}" ${lists} /dev/null 2>/dev/null;; esac } From bf4fada3b7188630ecb4656b123a94110998cacd Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Mon, 2 Mar 2020 09:52:06 -0800 Subject: [PATCH 3/3] Don't quote inside backticks, use unquoted variable. Signed-off-by: Dan Schaper --- advanced/Scripts/query.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh index 4dc9429d..7518e6c4 100755 --- a/advanced/Scripts/query.sh +++ b/advanced/Scripts/query.sh @@ -39,7 +39,7 @@ scanList(){ # If it does, print the matching regexp and continue looping # Input 1 - regexps | Input 2 - domainQuery "regex" ) - for list in `echo "${lists}"`; do + for list in ${lists}; do if [[ "${domain}" =~ ${list} ]]; then printf "%b\n" "${list}"; fi