From 63623c43538c5591c12771d06a28dae7f53ce347 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Fri, 4 Apr 2025 23:46:10 +0100 Subject: [PATCH] In ./advanced/Scripts/piholeCheckout.sh line 112: corebranches=($(get_available_branches "${PI_HOLE_FILES_DIR}")) ^-- SC2207 (warning): Prefer mapfile or read -a to split command output (or quote to avoid splitting). In ./advanced/Scripts/piholeCheckout.sh line 139: webbranches=($(get_available_branches "${webInterfaceDir}")) ^-- SC2207 (warning): Prefer mapfile or read -a to split command output (or quote to avoid splitting). In ./advanced/Scripts/piholeCheckout.sh line 170: ftlbranches=( $(git ls-remote https://github.com/pi-hole/ftl | grep "refs/heads" | cut -d'/' -f3- -) ) ^-- SC2207 (warning): Prefer mapfile or read -a to split command output (or quote to avoid splitting). In ./advanced/Scripts/piholeCheckout.sh line 218: elif [ $? -eq 2 ]; then ^-- SC2319 (warning): This $? refers to a condition, not a command. Assign to a variable to avoid it being overwritten. Signed-off-by: Adam Warner --- advanced/Scripts/piholeCheckout.sh | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/advanced/Scripts/piholeCheckout.sh b/advanced/Scripts/piholeCheckout.sh index 84c966df..58d62bc5 100755 --- a/advanced/Scripts/piholeCheckout.sh +++ b/advanced/Scripts/piholeCheckout.sh @@ -109,7 +109,7 @@ checkout() { echo -e "${OVER} ${CROSS} $str" exit 1 fi - corebranches=($(get_available_branches "${PI_HOLE_FILES_DIR}")) + mapfile -t corebranches < <(get_available_branches "${PI_HOLE_FILES_DIR}") if [[ "${corebranches[*]}" == *"master"* ]]; then echo -e "${OVER} ${TICK} $str" @@ -136,7 +136,7 @@ checkout() { echo -e "${OVER} ${CROSS} $str" exit 1 fi - webbranches=($(get_available_branches "${webInterfaceDir}")) + mapfile -t webbranches < <(get_available_branches "${webInterfaceDir}") if [[ "${webbranches[*]}" == *"master"* ]]; then echo -e "${OVER} ${TICK} $str" @@ -167,7 +167,7 @@ checkout() { # Check if requested branch is available echo -e " ${INFO} Checking for availability of branch ${COL_CYAN}${2}${COL_NC} on GitHub" - ftlbranches=( $(git ls-remote https://github.com/pi-hole/ftl | grep "refs/heads" | cut -d'/' -f3- -) ) + mapfile -t ftlbranches < <(git ls-remote https://github.com/pi-hole/ftl | grep "refs/heads" | cut -d'/' -f3- -) # If returned array is empty -> connectivity issue if [[ ${#ftlbranches[@]} -eq 0 ]]; then echo -e " ${CROSS} Unable to fetch branches from GitHub. Please check your Internet connection and try again later." @@ -209,13 +209,15 @@ checkout() { # Update local and remote versions via updatechecker /opt/pihole/updatecheck.sh else - if [ $? -eq 1 ]; then + local status + status=$? + if [ $status -eq 1 ]; then # Binary for requested branch is not available, may still be # int he process of being built or CI build job failed printf " %b Binary for requested branch is not available, please try again later.\\n" ${CROSS} printf " If the issue persists, please contact Pi-hole Support and ask them to re-generate the binary.\\n" exit 1 - elif [ $? -eq 2 ]; then + elif [ $status -eq 2 ]; then printf " %b Unable to download from ftl.pi-hole.net. Please check your Internet connection and try again later.\\n" "${CROSS}" exit 1 else