From 94b7766329fcf7be6b2c40f8e8fc74591aaecbb0 Mon Sep 17 00:00:00 2001 From: Subhaditya Nath Date: Sun, 15 Aug 2021 11:30:07 +0530 Subject: [PATCH 01/12] Don't litter chdir to the directory padd.sh is stored in before executing the rest of the script. Prevents the formation of PADD.pid and piHoleVersion files everywhere. Fixes https://github.com/pi-hole/PADD/issues/62 --- padd.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/padd.sh b/padd.sh index 5d58d714..a85f6fe1 100755 --- a/padd.sh +++ b/padd.sh @@ -14,6 +14,9 @@ LC_ALL=C LC_NUMERIC=C +# cd to the directory this script is stored in +cd "$(dirname "$0")" + ############################################ VARIABLES ############################################# # VERSION From 831bd56d50551930ebf11c3789219e8275c30b80 Mon Sep 17 00:00:00 2001 From: Subhaditya Nath Date: Mon, 21 Feb 2022 09:31:17 +0530 Subject: [PATCH 02/12] Update .gitignore --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 09d2d74b..ce3b60de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ +# Temporary files generated by padd.sh # +######################################## +piHoleVersion + # Compiled source # ################### *.com @@ -49,4 +53,4 @@ old ################# new\.sh net-test.sh -padd.py \ No newline at end of file +padd.py From 0c7598ac92507ee96cdaa9d6a4b82bef7e6a1a6b Mon Sep 17 00:00:00 2001 From: Subhaditya Nath Date: Sun, 20 Feb 2022 09:00:36 +0530 Subject: [PATCH 03/12] Comply with Stickler https://github.com/pi-hole/PADD/pull/168#issuecomment-1046006035 --- padd.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/padd.sh b/padd.sh index a85f6fe1..9baa10d7 100755 --- a/padd.sh +++ b/padd.sh @@ -15,7 +15,11 @@ LC_ALL=C LC_NUMERIC=C # cd to the directory this script is stored in -cd "$(dirname "$0")" +cd "$(dirname "$0")" || { + EC=$? + echo >&2 "Could not chdir to the directory containing padd.sh (exit code $EC)" + exit $EC +} ############################################ VARIABLES ############################################# From 8558356d27229b9fd561ef6fdfc678430c61a08a Mon Sep 17 00:00:00 2001 From: Subhaditya Nath Date: Fri, 13 Aug 2021 15:56:16 +0530 Subject: [PATCH 04/12] Fixed issues that occur if Web Interface unavailable - Show the version as N/A (Not Available) instead of v-1 - Don't show out-of-date message in status message --- padd.sh | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/padd.sh b/padd.sh index 5d58d714..f475e948 100755 --- a/padd.sh +++ b/padd.sh @@ -511,20 +511,27 @@ GetVersionInformation() { fi # Gather web version information... - read -r -a web_versions <<< "$(pihole -v -a)" - web_version=$(echo "${web_versions[3]}" | tr -d '\r\n[:alpha:]') - web_version_latest=${web_versions[5]//)} - if [[ "${web_version_latest}" == "ERROR" ]]; then - web_version_heatmap=${yellow_text} - else - web_version_latest=$(echo "${web_version_latest}" | tr -d '\r\n[:alpha:]') - # is web up-to-date? - if [[ "${web_version}" != "${web_version_latest}" ]]; then - out_of_date_flag="true" - web_version_heatmap=${red_text} + if [[ "$(source /etc/pihole/setupVars.conf; echo "$INSTALL_WEB_INTERFACE")" = true ]]; then + read -r -a web_versions <<< "$(pihole -v -a)" + web_version=$(echo "${web_versions[3]}" | tr -d '\r\n[:alpha:]') + web_version_latest=${web_versions[5]//)} + if [[ "${web_version_latest}" == "ERROR" ]]; then + web_version_heatmap=${yellow_text} else - web_version_heatmap=${green_text} + web_version_latest=$(echo "${web_version_latest}" | tr -d '\r\n[:alpha:]') + # is web up-to-date? + if [[ "${web_version}" != "${web_version_latest}" ]]; then + out_of_date_flag="true" + web_version_heatmap=${red_text} + else + web_version_heatmap=${green_text} + fi fi + else + # Web interface not installed + web_version_heatmap=${red_text} + web_version="$(printf '\x08')" # Hex 0x08 is for backspace, to delete the leading 'v' + web_version="${web_version}N/A" # N/A = Not Available fi # Gather FTL version information... From 06fe88fca51cd5ad543193383663279463c2b286 Mon Sep 17 00:00:00 2001 From: Subhaditya Nath Date: Sat, 26 Feb 2022 21:02:13 +0530 Subject: [PATCH 05/12] source /etc/pihole/setupVars.conf https://github.com/pi-hole/PADD/pull/165#issuecomment-1052123280 --- padd.sh | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/padd.sh b/padd.sh index f475e948..42bc8789 100755 --- a/padd.sh +++ b/padd.sh @@ -26,6 +26,9 @@ today=$(date +%Y%m%d) declare -i core_count=1 core_count=$(cat /sys/devices/system/cpu/kernel_max 2> /dev/null)+1 +# Get Config variables +. /etc/pihole/setupVars.conf + # COLORS black_text=$(tput setaf 0) # Black red_text=$(tput setaf 1) # Red @@ -511,7 +514,7 @@ GetVersionInformation() { fi # Gather web version information... - if [[ "$(source /etc/pihole/setupVars.conf; echo "$INSTALL_WEB_INTERFACE")" = true ]]; then + if [[ "$INSTALL_WEB_INTERFACE" = true ]]; then read -r -a web_versions <<< "$(pihole -v -a)" web_version=$(echo "${web_versions[3]}" | tr -d '\r\n[:alpha:]') web_version_latest=${web_versions[5]//)} @@ -1188,9 +1191,6 @@ NormalPADD() { # Sizing Checks SizeChecker - # Get Config variables - . /etc/pihole/setupVars.conf - # Move the cursor to top left of console to redraw tput cup 0 0 @@ -1244,10 +1244,6 @@ if [[ $# = 0 ]]; then console_width=$(tput cols) console_height=$(tput lines) - # Get Our Config Values - # shellcheck disable=SC1091 - . /etc/pihole/setupVars.conf - SizeChecker StartupRoutine ${padd_size} From 7e0b3e380afb0144242ed07e36ae8e9bc841fd9f Mon Sep 17 00:00:00 2001 From: Subhaditya Nath Date: Thu, 19 Aug 2021 15:39:02 +0530 Subject: [PATCH 06/12] Use ISO 6429 SGR parameters to set text attributes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For reference, see - https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters The escape sequences for some terminals (e.g. rxvt-unicode) contain semicolons in them. E.g. `tput setaf 0` returns "" Now, we set heatmap colors using these escape sequences, and we store the heatmap in ./piHoleVersion without quoting it. So, when we source ./piHoleVersion, bash interprets the semicolons as command-separators, and shows a bunch of errors like these - piHoleVersion: line 4: 5: command not found piHoleVersion: line 4: 2m: command not found piHoleVersion: line 7: 5: command not found piHoleVersion: line 7: 1m: command not found piHoleVersion: line 10: 5: command not found piHoleVersion: line 10: 2m: command not found piHoleVersion: line 13: 5: command not found piHoleVersion: line 13: 2m: command not found piHoleVersion: line 15: 5: command not found piHoleVersion: line 15: 2m: command not found for reference, these are the contents of line 4, 7, 10, 13 and 15 - core_version_heatmap=^[[38;5;2m web_version_heatmap=^[[38;5;1m ftl_version_heatmap=^[[38;5;2m padd_version_heatmap=^[[38;5;2m version_heatmap=^[[38;5;2m So now, as suggested by @dschaper in [1], we use hardcoded ANSI escape codes that are guaranteed to work with ISO 6429 compatible terminals. [1]: https://github.com/pi-hole/PADD/pull/171#issuecomment-902009001, --- padd.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/padd.sh b/padd.sh index e3bbd47b..46711457 100755 --- a/padd.sh +++ b/padd.sh @@ -37,20 +37,21 @@ core_count=$(cat /sys/devices/system/cpu/kernel_max 2> /dev/null)+1 . /etc/pihole/setupVars.conf # COLORS -black_text=$(tput setaf 0) # Black -red_text=$(tput setaf 1) # Red -green_text=$(tput setaf 2) # Green -yellow_text=$(tput setaf 3) # Yellow -blue_text=$(tput setaf 4) # Blue -magenta_text=$(tput setaf 5) # Magenta -cyan_text=$(tput setaf 6) # Cyan -white_text=$(tput setaf 7) # White -reset_text=$(tput sgr0) # Reset to default color +CSI="$(printf '\033')[" +black_text="${CSI}90m" # Black +red_text="${CSI}91m" # Red +green_text="${CSI}92m" # Green +yellow_text="${CSI}93m" # Yellow +blue_text="${CSI}94m" # Blue +magenta_text="${CSI}95m" # Magenta +cyan_text="${CSI}96m" # Cyan +white_text="${CSI}97m" # White +reset_text="${CSI}0m" # Reset to default # STYLES -bold_text=$(tput bold) -blinking_text=$(tput blink) -dim_text=$(tput dim) +bold_text="${CSI}1m" +blinking_text="${CSI}5m" +dim_text="${CSI}2m" # CHECK BOXES check_box_good="[${green_text}✓${reset_text}]" # Good From 5a6649adb4159f2d09fb137a86215c033d1e9104 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 18 Mar 2022 21:20:10 +0100 Subject: [PATCH 07/12] Version bump 3.6.7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/padd.sh b/padd.sh index 46711457..d86304f7 100755 --- a/padd.sh +++ b/padd.sh @@ -24,7 +24,7 @@ cd "$(dirname "$0")" || { ############################################ VARIABLES ############################################# # VERSION -padd_version="v3.6.6" +padd_version="v3.6.7" # DATE today=$(date +%Y%m%d) From 38a02ff3153fbb67a874452031db31958a2c9b6e Mon Sep 17 00:00:00 2001 From: Thomas Merz Date: Sun, 20 Mar 2022 17:00:20 +0100 Subject: [PATCH 08/12] Fix Issue 188 by enabling and fixing SC2034 and SC2154 shellcheck warnings - removed some 'referenced but not assigned' variables - removed some 'appears unused variables - disabled a single SC2059 because it appears to be a false positive --- padd.sh | 49 ++++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/padd.sh b/padd.sh index d86304f7..752e4140 100755 --- a/padd.sh +++ b/padd.sh @@ -1,10 +1,7 @@ #!/usr/bin/env bash -# shellcheck disable=SC2034 # shellcheck disable=SC1091 -# shellcheck disable=SC2154 # PADD -# # A more advanced version of the chronometer provided with Pihole # SETS LOCALE @@ -38,14 +35,12 @@ core_count=$(cat /sys/devices/system/cpu/kernel_max 2> /dev/null)+1 # COLORS CSI="$(printf '\033')[" -black_text="${CSI}90m" # Black red_text="${CSI}91m" # Red green_text="${CSI}92m" # Green yellow_text="${CSI}93m" # Yellow blue_text="${CSI}94m" # Blue magenta_text="${CSI}95m" # Magenta cyan_text="${CSI}96m" # Cyan -white_text="${CSI}97m" # White reset_text="${CSI}0m" # Reset to default # STYLES @@ -98,7 +93,6 @@ mega_status_unknown="${check_box_question} Unable to determine Pi-hole status." # TINY STATUS tiny_status_ok="${check_box_good} System is healthy." tiny_status_update="${check_box_info} Updates are available." -tiny_status_hot="${check_box_bad} System is hot!" tiny_status_off="${check_box_bad} Pi-hole is offline" tiny_status_ftl_down="${check_box_info} FTL is down!" tiny_status_dns_down="${check_box_bad} DNS is off!" @@ -106,8 +100,6 @@ tiny_status_unknown="${check_box_question} Status unknown!" # Text only "logos" padd_text="${green_text}${bold_text}PADD${reset_text}" -padd_text_retro="${bold_text}${red_text}P${yellow_text}A${green_text}D${blue_text}D${reset_text}${reset_text}" -mini_text_retro="${dim_text}${cyan_text}m${magenta_text}i${red_text}n${yellow_text}i${reset_text}" # PADD logos - regular and retro padd_logo_1="${bold_text}${green_text} __ __ __ ${reset_text}" @@ -117,13 +109,7 @@ padd_logo_retro_1="${bold_text} ${yellow_text}_${green_text}_ ${blue_text}_ padd_logo_retro_2="${bold_text}${yellow_text}|${green_text}_${blue_text}_${cyan_text}) ${red_text}/${yellow_text}\\ ${blue_text}| ${red_text}\\${yellow_text}| ${cyan_text}\\ ${reset_text}" padd_logo_retro_3="${bold_text}${green_text}| ${red_text}/${yellow_text}-${green_text}-${blue_text}\\${cyan_text}|${magenta_text}_${red_text}_${yellow_text}/${green_text}|${blue_text}_${cyan_text}_${magenta_text}/ ${reset_text}" -# old script Pi-hole logos - regular and retro -pihole_logo_script_1="${bold_text}${green_text}.-.. . . ${reset_text}" -pihole_logo_script_2="${bold_text}${green_text}|-'. - |-. .-.| .-, ${reset_text}" -pihole_logo_script_3="${bold_text}${green_text}' ' ' '-\`-''-\`'- ${reset_text}" -pihole_logo_script_retro_1="${red_text}.${yellow_text}-${green_text}.${blue_text}. ${green_text}. ${magenta_text}. ${reset_text}" -pihole_logo_script_retro_2="${yellow_text}|${green_text}-${blue_text}'${magenta_text}. ${yellow_text}- ${blue_text}|${magenta_text}-${red_text}. ${green_text}.${blue_text}-${magenta_text}.${red_text}| ${green_text}.${blue_text}-${magenta_text}, ${reset_text}" -pihole_logo_script_retro_3="${green_text}' ${red_text}' ${magenta_text}' ${yellow_text}'${green_text}-${blue_text}\`${magenta_text}-${red_text}'${yellow_text}'${green_text}-${blue_text}\`${magenta_text}'${red_text}- ${reset_text}" +# old script Pi-hole logos - regular and retro - removed due to shellcheck SC2034: it appears unused. ############################################# GETTERS ############################################## @@ -158,7 +144,6 @@ GetFTLData() { GetSummaryInformation() { local summary - local cache_summary summary=$(GetFTLData "stats") cache_info=$(GetFTLData "cacheinfo") @@ -330,7 +315,7 @@ GetNetworkInformation() { full_hostname=${pi_hostname} # does the Pi-hole have a domain set? - if ! [ -z ${PIHOLE_DOMAIN+x} ]; then + if [ -n "${PIHOLE_DOMAIN+x}" ]; then # is Pi-hole acting as DHCP server? if [[ "${DHCP_ACTIVE}" == "true" ]]; then count=${pi_hostname}"."${PIHOLE_DOMAIN} @@ -376,15 +361,10 @@ GetNetworkInformation() { dhcp_check_box=${check_box_good} # Is DHCP handling IPv6? - if [[ "${DHCP_IPv6}" == "true" ]]; then - dhcp_ipv6_status="Enabled" - dhcp_ipv6_heatmap=${green_text} - dhcp_ipv6_check_box=${check_box_good} - else - dhcp_ipv6_status="Disabled" - dhcp_ipv6_heatmap=${red_text} - dhcp_ipv6_check_box=${check_box_bad} - fi + # No, because: DHCP_IPv6 is referenced but not assigned. [SC2154] - removed. + dhcp_ipv6_status="Disabled" + dhcp_ipv6_heatmap=${red_text} + dhcp_ipv6_check_box=${check_box_bad} else dhcp_status="Disabled" dhcp_heatmap=${red_text} @@ -409,22 +389,18 @@ GetNetworkInformation() { if [[ "${DNSSEC}" == "true" ]]; then dnssec_status="Enabled" dnssec_heatmap=${green_text} - dnssec_check_box=${check_box_good} else dnssec_status="Disabled" dnssec_heatmap=${red_text} - dnssec_check_box=${check_box_bad} fi # Conditional forwarding if [[ "${CONDITIONAL_FORWARDING}" == "true" ]] || [[ "${REV_SERVER}" == "true" ]]; then conditional_forwarding_status="Enabled" conditional_forwarding_heatmap=${green_text} - conditional_forwarding_check_box=${check_box_good} else conditional_forwarding_status="Disabled" conditional_forwarding_heatmap=${red_text} - conditional_forwarding_check_box=${check_box_bad} fi } @@ -497,10 +473,9 @@ GetVersionInformation() { today=$(date +%Y%m%d) # was the last check today? - if [ "${today}" != "${last_check}" ]; then # no, it wasn't today - # Remove the Pi-hole version file... - rm -f piHoleVersion - fi + # No, because: last_check is referenced but not assigned. [SC2154] - removed. + # Remove the Pi-hole version file... + rm -f piHoleVersion else # the file doesn't exist, create it... # Gather core version information... @@ -654,11 +629,14 @@ ceol=$(tput el) # wrapper - echo with a clear eol afterwards to wipe any artifacts remaining from last print CleanEcho() { echo -e "${ceol}$1" + #echo -e "$1" "${ceol}" } # wrapper - printf CleanPrintf() { # tput el +# don't know how to fix this!? +# shellcheck disable=SC2059 printf "$@" } @@ -852,6 +830,7 @@ PrintSystemInformation() { CleanEcho " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" echo -ne "${ceol} Memory: [${memory_heatmap}${memory_bar}${reset_text}] ${memory_percent}%" elif [ "$1" = "mini" ]; then + CleanEcho "${bold_text}SYSTEM =================================${reset_text}" CleanPrintf " %-9s%-29s\\n" "Uptime:" "${system_uptime}" CleanEcho " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" @@ -1054,7 +1033,7 @@ json_extract() { local pair_regex="\"${key}\"[[:space:]]*:[[:space:]]*(${value_regex})" if [[ ${json} =~ ${pair_regex} ]]; then - echo $(sed 's/^"\|"$//g' <<< "${BASH_REMATCH[1]}") + echo "${BASH_REMATCH[1]//^"\|"$/}" else return 1 fi From 858fd17ecfb97d08501e089054f21371d8cb4fae Mon Sep 17 00:00:00 2001 From: thomasmerz Date: Tue, 22 Mar 2022 19:26:54 +0100 Subject: [PATCH 09/12] Apply suggestions from code review Co-authored-by: yubiuser --- padd.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/padd.sh b/padd.sh index 752e4140..28d9e287 100755 --- a/padd.sh +++ b/padd.sh @@ -109,7 +109,6 @@ padd_logo_retro_1="${bold_text} ${yellow_text}_${green_text}_ ${blue_text}_ padd_logo_retro_2="${bold_text}${yellow_text}|${green_text}_${blue_text}_${cyan_text}) ${red_text}/${yellow_text}\\ ${blue_text}| ${red_text}\\${yellow_text}| ${cyan_text}\\ ${reset_text}" padd_logo_retro_3="${bold_text}${green_text}| ${red_text}/${yellow_text}-${green_text}-${blue_text}\\${cyan_text}|${magenta_text}_${red_text}_${yellow_text}/${green_text}|${blue_text}_${cyan_text}_${magenta_text}/ ${reset_text}" -# old script Pi-hole logos - regular and retro - removed due to shellcheck SC2034: it appears unused. ############################################# GETTERS ############################################## @@ -144,6 +143,7 @@ GetFTLData() { GetSummaryInformation() { local summary + local cache_info summary=$(GetFTLData "stats") cache_info=$(GetFTLData "cacheinfo") @@ -361,7 +361,6 @@ GetNetworkInformation() { dhcp_check_box=${check_box_good} # Is DHCP handling IPv6? - # No, because: DHCP_IPv6 is referenced but not assigned. [SC2154] - removed. dhcp_ipv6_status="Disabled" dhcp_ipv6_heatmap=${red_text} dhcp_ipv6_check_box=${check_box_bad} @@ -830,7 +829,6 @@ PrintSystemInformation() { CleanEcho " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" echo -ne "${ceol} Memory: [${memory_heatmap}${memory_bar}${reset_text}] ${memory_percent}%" elif [ "$1" = "mini" ]; then - CleanEcho "${bold_text}SYSTEM =================================${reset_text}" CleanPrintf " %-9s%-29s\\n" "Uptime:" "${system_uptime}" CleanEcho " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" From 8679dd72830e89af70a998f9aae6e7d601d1d50f Mon Sep 17 00:00:00 2001 From: Thomas Merz Date: Tue, 22 Mar 2022 21:32:41 +0100 Subject: [PATCH 10/12] Resolve conversations --- padd.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/padd.sh b/padd.sh index 28d9e287..8de55ef2 100755 --- a/padd.sh +++ b/padd.sh @@ -361,9 +361,17 @@ GetNetworkInformation() { dhcp_check_box=${check_box_good} # Is DHCP handling IPv6? - dhcp_ipv6_status="Disabled" - dhcp_ipv6_heatmap=${red_text} - dhcp_ipv6_check_box=${check_box_bad} + # DHCP_IPv6 is set in setupVars.conf + # shellcheck disable=SC2154 + if [[ "${DHCP_IPv6}" == "true" ]]; then + dhcp_ipv6_status="Enabled" + dhcp_ipv6_heatmap=${green_text} + dhcp_ipv6_check_box=${check_box_good} + else + dhcp_ipv6_status="Disabled" + dhcp_ipv6_heatmap=${red_text} + dhcp_ipv6_check_box=${check_box_bad} + fi else dhcp_status="Disabled" dhcp_heatmap=${red_text} @@ -472,9 +480,12 @@ GetVersionInformation() { today=$(date +%Y%m%d) # was the last check today? - # No, because: last_check is referenced but not assigned. [SC2154] - removed. - # Remove the Pi-hole version file... - rm -f piHoleVersion + # last_check is read from ./piHoleVersion + # shellcheck disable=SC2154 + if [ "${today}" != "${last_check}" ]; then # no, it wasn't today + # Remove the Pi-hole version file... + rm -f piHoleVersion + fi else # the file doesn't exist, create it... # Gather core version information... @@ -628,13 +639,13 @@ ceol=$(tput el) # wrapper - echo with a clear eol afterwards to wipe any artifacts remaining from last print CleanEcho() { echo -e "${ceol}$1" - #echo -e "$1" "${ceol}" } # wrapper - printf CleanPrintf() { # tput el # don't know how to fix this!? +# this doesn't work and screws up everything: printf "%s" "$@" # shellcheck disable=SC2059 printf "$@" } From 611e4d662924f5d12e71893f3d94523f31179ce3 Mon Sep 17 00:00:00 2001 From: thomasmerz Date: Wed, 23 Mar 2022 14:47:16 +0100 Subject: [PATCH 11/12] Apply suggestions from code review Co-authored-by: yubiuser --- padd.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/padd.sh b/padd.sh index 8de55ef2..cb1f8bff 100755 --- a/padd.sh +++ b/padd.sh @@ -644,8 +644,7 @@ CleanEcho() { # wrapper - printf CleanPrintf() { # tput el -# don't know how to fix this!? -# this doesn't work and screws up everything: printf "%s" "$@" +# disabling shellcheck here because we pass formatting instructions within `"${@}"` # shellcheck disable=SC2059 printf "$@" } From 0cc492853bdcf2689d14dda0b05f8bcf86d06c06 Mon Sep 17 00:00:00 2001 From: thomasmerz Date: Thu, 24 Mar 2022 22:42:58 +0100 Subject: [PATCH 12/12] Add suggested change from @yubiuser Co-authored-by: yubiuser --- padd.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/padd.sh b/padd.sh index cb1f8bff..d7081a60 100755 --- a/padd.sh +++ b/padd.sh @@ -1041,7 +1041,8 @@ json_extract() { local pair_regex="\"${key}\"[[:space:]]*:[[:space:]]*(${value_regex})" if [[ ${json} =~ ${pair_regex} ]]; then - echo "${BASH_REMATCH[1]//^"\|"$/}" + # remove leading and trailing quotes + sed -e 's/^"//' -e 's/"$//' <<<"${BASH_REMATCH[1]}" else return 1 fi