From 3c09cd4a3ae296a6ed2d061f30cb433aa044bf45 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 21 Feb 2020 21:41:28 +0100 Subject: [PATCH] Experimental output of matching line from shown warnings. Signed-off-by: DL6ER --- gravity.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index b9abd83d..eac0acfe 100755 --- a/gravity.sh +++ b/gravity.sh @@ -391,7 +391,29 @@ gravity_DownloadBlocklists() { fi if [[ "${status}" -eq 0 && -n "${output}" ]]; then - echo -e " Encountered non-critical SQL warnings. Please check the suitability of the list you're using!\\nSQL warnings:\\n${output}\\n" + echo -e " Encountered non-critical SQL warnings. Please check the suitability of the lists you're using!\\n\\n SQL warnings:" + local warning file line lineno + while IFS= read -r line; do + echo " - ${line}" + warning="$(grep -oh "^[^:]*:[0-9]*" <<< "${line}")" + file="${warning%:*}" + lineno="${warning#*:}" + if [[ -n "${file}" && -n "${lineno}" ]]; then + echo -n " Line contains: " + awk "NR==${lineno}" < ${file} + fi + done <<< "${output}" + echo "" + local file line + while IFS= read -r line; do + warning="$(grep -oh "^[^:]*:[0-9]*" <<< "${line}")" + file="${warning%:*}" + lineno="${warning#*:}" + if [[ -n "${file}" && -n "${lineno}" ]]; then + echo -n "Line contains: " + awk "NR==${lineno}" < ${file} + fi + done <<< "${output}" fi rm "${target}" > /dev/null 2>&1 || \