From e05b6b911d24e096f76fb8daa661a36cbbde95a3 Mon Sep 17 00:00:00 2001 From: hophacker Date: Sun, 21 Feb 2021 16:26:54 +0800 Subject: [PATCH] use RANDDOM var instead of shuf command to avoid dep issue, shorten code --- zsh/k8s.zsh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/zsh/k8s.zsh b/zsh/k8s.zsh index 956ba39..4cb2a78 100644 --- a/zsh/k8s.zsh +++ b/zsh/k8s.zsh @@ -64,14 +64,9 @@ function getpod { echo "Pod not found for $PROJECT" break fi - if [[ $RAN == 'true' ]];then - RUNNING_POD_INDEX=`shuf -i 1-${#RUNNING_PODS[@]} -n 1` - break - fi - if [ ${#RUNNING_PODS[@]} -eq 1 ];then - RUNNING_POD_INDEX=1 - break - elif [ ${#RUNNING_PODS[@]} -gt 1 ];then + RUNNING_POD_INDEX=$(($RANDOM % ${#RUNNING_PODS[@]} + 1)) + [[ $RAN == 'true' ]] && break + if [ ${#RUNNING_PODS[@]} -gt 1 ];then echo $fg[green]'Running Pods:'$reset_color INDEX=1 for i in $RUNNING_PODS;do