Skip to content

Commit aed2e35

Browse files
committed
Print messages only after removing possible matches in comments.
Signed-off-by: DL6ER <[email protected]>
1 parent e7af42a commit aed2e35

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

advanced/Scripts/query.sh

+13-15
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,6 @@ lists=("$(cd "$piholeDir" || exit 0; printf "%s\\n" -- *.domains | sort -V)")
157157
# Query blocklists for occurences of domain
158158
mapfile -t results <<< "$(scanList "${domainQuery}" "${lists[*]}" "${exact}")"
159159

160-
# Handle notices
161-
if [[ -z "${wbMatch:-}" ]] && [[ -z "${wcMatch:-}" ]] && [[ -z "${results[*]}" ]]; then
162-
echo -e " ${INFO} No ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} within the block lists"
163-
exit 0
164-
elif [[ -z "${results[*]}" ]]; then
165-
# Result found in WL/BL/Wildcards
166-
exit 0
167-
elif [[ -z "${all}" ]] && [[ "${#results[*]}" -ge 100 ]]; then
168-
echo -e " ${INFO} Over 100 ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC}
169-
This can be overridden using the -all option"
170-
exit 0
171-
fi
172-
173160
# Remove unwanted content from $results
174161
# Each line in $results is formatted as such: [fileName]:[line]
175162
# 1. Delete lines starting with #
@@ -183,8 +170,19 @@ mapfile -t results <<< "$(IFS=$'\n'; sed \
183170
-e "s/:.*[ \\t]/:/g" \
184171
-e "/${esc_domain}/!d" \
185172
<<< "${results[*]}")"
186-
# Exit if result was in a comment
187-
[[ -z "${results[*]}" ]] && exit 0
173+
174+
# Handle notices
175+
if [[ -z "${wbMatch:-}" ]] && [[ -z "${wcMatch:-}" ]] && [[ -z "${results[*]}" ]]; then
176+
echo -e " ${INFO} No ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC} within the block lists"
177+
exit 0
178+
elif [[ -z "${results[*]}" ]]; then
179+
# Result found in WL/BL/Wildcards
180+
exit 0
181+
elif [[ -z "${all}" ]] && [[ "${#results[*]}" -ge 100 ]]; then
182+
echo -e " ${INFO} Over 100 ${exact/t/t }results found for ${COL_BOLD}${domainQuery}${COL_NC}
183+
This can be overridden using the -all option"
184+
exit 0
185+
fi
188186
189187
# Get adlist file content as array
190188
if [[ -n "${adlist}" ]] || [[ -n "${blockpage}" ]]; then

0 commit comments

Comments
 (0)