From c6d0926fc2b2aa390aa57974814e6c22d8e03757 Mon Sep 17 00:00:00 2001 From: Heavybullets8 Date: Wed, 10 Aug 2022 17:41:51 -0600 Subject: [PATCH] works --- functions/cmd_to_container.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/functions/cmd_to_container.sh b/functions/cmd_to_container.sh index 70484252..d1dc1870 100644 --- a/functions/cmd_to_container.sh +++ b/functions/cmd_to_container.sh @@ -28,15 +28,14 @@ mapfile -t pod_id < <(echo "$search" | grep -E "[[:space:]]$app_name([[:space:]] for pod in "${pod_id[@]}" do containers+=("$(echo "$search" | grep "$pod" | awk '{print $4}')") - echo "${#containers[@]}" done -if [[ "${#containers[@]}" == 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 +if [[ "${#containers[@]}" == 0 ]]; then echo -e "No containers available\nAre you sure the application in running?" exit +elif [[ "${#containers[@]}" == 1 ]]; then + container=$(echo "$search" | grep "${pod_id[*]}" | awk '{print $4}') + container_id=$(echo "$search" | grep -E "[[:space:]]${container}[[:space:]]" | awk '{print $1}') else while true do