Highlight "### CHANGED" strings in the debug log of pihole.toml

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER 2024-03-09 11:17:33 +01:00
parent 0635ea7455
commit c02401b81e
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD

View file

@ -865,8 +865,6 @@ make_array_from_file() {
local limit=${2} local limit=${2}
# A local iterator for testing if we are at the limit above # A local iterator for testing if we are at the limit above
local i=0 local i=0
# Set the array to be empty so we can start fresh when the function is used
local file_content=()
# If the file is a directory # If the file is a directory
if [[ -d "${filename}" ]]; then if [[ -d "${filename}" ]]; then
# do nothing since it cannot be parsed # do nothing since it cannot be parsed
@ -878,11 +876,14 @@ make_array_from_file() {
new_line=$(echo "${line}" | sed -e 's/^\s*#.*$//' -e '/^$/d') new_line=$(echo "${line}" | sed -e 's/^\s*#.*$//' -e '/^$/d')
# If the line still has content (a non-zero value) # If the line still has content (a non-zero value)
if [[ -n "${new_line}" ]]; then if [[ -n "${new_line}" ]]; then
# Put it into the array
file_content+=("${new_line}") # If the string contains "### CHANGED", highlight this part in red
else if [[ "${new_line}" == *"### CHANGED"* ]]; then
# Otherwise, it's a blank line or comment, so do nothing new_line="${new_line//### CHANGED/${COL_RED}### CHANGED${COL_NC}}"
: fi
# Finally, write this line to the log
log_write " ${new_line}"
fi fi
# Increment the iterator +1 # Increment the iterator +1
i=$((i+1)) i=$((i+1))
@ -894,12 +895,6 @@ make_array_from_file() {
break break
fi fi
done < "${filename}" done < "${filename}"
# Now the we have made an array of the file's content
for each_line in "${file_content[@]}"; do
# Print each line
# At some point, we may want to check the file line-by-line, so that's the reason for an array
log_write " ${each_line}"
done
fi fi
} }