From 43bced7997772d5604d1302e1c8fbc6369ec45e1 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 25 Apr 2019 12:45:08 +0200 Subject: [PATCH] Add more comments Signed-off-by: DL6ER --- advanced/Scripts/list.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/list.sh b/advanced/Scripts/list.sh index 727919fe..5fd24f6b 100755 --- a/advanced/Scripts/list.sh +++ b/advanced/Scripts/list.sh @@ -24,8 +24,8 @@ listType="" listname="" sqlitekey="" -# shellcheck source=/opt/pihole/COL_TABLE -source "/opt/pihole/COL_TABLE" +colfile="/opt/pihole/COL_TABLE" +source ${colfile} helpFunc() { @@ -63,7 +63,7 @@ EscapeRegexp() { # string in our regular expressions # This sed is intentionally executed in three steps to ease maintainability # The first sed removes any amount of leading dots - echo "$@" | sed 's/^\.*//' | sed "s/[]\.|$(){}?+*^]/\\\\&/g" | sed "s/\\//\\\\\//g" + echo $* | sed 's/^\.*//' | sed "s/[]\.|$(){}?+*^]/\\\\&/g" | sed "s/\\//\\\\\//g" } HandleOther() { @@ -190,8 +190,11 @@ Displaylist() { # pipe symbols as they are perfectly valid regex filter control characters num_pipes="$(grep -c "^" <<< "$(grep -o "|" <<< "${line}")")" + # Extract domain and enabled status based on the obtained number of pipe characters domain="$(cut -d'|' -f"-$((num_pipes-2))" <<< "${line}")" - enabled="$(cut -d'|' -f$((num_pipes-1)) <<< "${line}")" + enabled="$(cut -d'|' -f"$((num_pipes-1))" <<< "${line}")" + + # Translate boolean status into human readable string if [[ "${enabled}" -eq 1 ]]; then status="enabled" else