From f80fdd7e83b4bb23edb1671316f986b9ed791b68 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Sat, 4 May 2019 13:19:50 +0200 Subject: [PATCH] Improve comments Signed-off-by: DL6ER --- advanced/Scripts/query.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/query.sh b/advanced/Scripts/query.sh index 66b55e87..a7cc9dfb 100755 --- a/advanced/Scripts/query.sh +++ b/advanced/Scripts/query.sh @@ -108,10 +108,10 @@ scanDatabaseTable() { table="${2}" type="${3:-}" - # As underscores are legitimate parts of domains, we escape possible them when using the LIKE operator. - # Underscores are a SQLite wildcard matching exactly one character. We obviously want to suppress this + # As underscores are legitimate parts of domains, we escape them when using the LIKE operator. + # Underscores are SQLite wildcards matching exactly one character. We obviously want to suppress this # behavior. The "ESCAPE '\'" clause specifies that an underscore preceded by an '\' should be matched - # as a literal underscore character. + # as a literal underscore character. We pretreat the $domain variable accordingly to escape underscores. case "${type}" in "exact" ) querystr="SELECT domain FROM vw_${table} WHERE domain = '${domain}'";; * ) querystr="SELECT domain FROM vw_${table} WHERE domain LIKE '%${domain//_/\\_}%' ESCAPE '\'";; @@ -120,13 +120,14 @@ scanDatabaseTable() { # Send prepared query to gravity database result="$(sqlite3 "${gravityDBfile}" "${querystr}")" 2> /dev/null if [[ -z "${result}" ]]; then - # Return early when we have no results + # Return early when there are no matches in this table return fi + # Mark domain as having been white-/blacklist matched (global variable) wbMatch=true - mapfile -t results <<< "${result}" # Loop through each result + mapfile -t results <<< "${result}" for result in "${results[@]}"; do if [[ -n "${blockpage}" ]]; then echo "π ${result}"