From dc1f9bb6030b5c4dd98bee095be2e534ba8e1f41 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:16:45 -0600 Subject: [PATCH] replace ind check with count --- functions/cmd_to_container.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 00c0e6d5..6df7509e 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -25,12 +25,14 @@ done app_name=$(echo -e "$app_name" | grep ^"$selection)" | awk '{print $2}') search=$(k3s crictl ps -a -s running | sed -E 's/([0-9]*|About)[[:space:]][a-z]{2,5}[[:space:]](hour)?[[:space:]]?ago//') mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]]|-([-[:alnum:]])*[[:space:]])" | awk '{print $(NF)}') +count=0 for pod in "${pod_id[@]}" do mapfile -t containers < <(echo "$search" | grep "$pod" | awk '{print $4}') + ((count++)) done -if [[ "${#containers[@]}" == 1 && "${#pod_id[@]}" == 1 ]]; then +if [[ $count == 1 ]]; then container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') elif [[ "${#containers[@]}" == 0 ]]; then