From 61e46514d9e3bcd35e0ed41e19ee375bfb3444ca Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Fri, 12 Aug 2022 09:51:06 -0600 Subject: [PATCH] use 0 element in array if 0-1 are equal --- functions/cmd_to_container.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index b2938c9a..6e7be5d7 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -27,9 +27,8 @@ search=$(k3s crictl ps -a -s running | sed -E 's/[[:space:]]([0-9]*|About)[a-z0- mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') for pod in "${pod_id[@]}" do - printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" && continue - containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")") - echo "ADDED" "$(echo "$search" | grep "$pod" | awk '{print $4}' | tr -d " \t\r ")" + printf '%s\0' "${containers[@]}" | grep -Fxqz -- "$(echo "$search" | grep "$pod" | awk '{print $4}')" && continue + containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") done case "${#containers[@]}" in 0)