fix bug that kexec can't get running pod due to preceding for 'wc -l'

This commit is contained in:
hophacker 2021-01-14 21:15:47 +08:00
parent 6231d9dba4
commit 0f7cc981ce
3 changed files with 16 additions and 2 deletions

14
zsh/0001_core.zsh Normal file
View File

@ -0,0 +1,14 @@
trim() {
local var
if (( $# == 0 )) ; then
var=$(</dev/stdin)
else
var="$*"
fi
# remove leading whitespace characters
var="${var#"${var%%[![:space:]]*}"}"
# remove trailing whitespace characters
var="${var%"${var##*[![:space:]]}"}"
printf '%s' "$var"
}

View File

@ -264,4 +264,4 @@ alias yarn_sass="SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass/ yarn
alias vim="nvim"
## source files
alias ss="source ~/.yadr/zsh/functions.zsh; source ~/.yadr/zsh/aliases.zsh"
alias ss="source ~/.zshrc"

View File

@ -39,7 +39,7 @@ function getpod {
break
fi
RUNNING_PODS=($(echo $ALL_PODS | egrep "$PROJECT.* ?[1-9]/[0-9]? *Running" | awk '{print $1}'))
if [[ `echo $ALL_PODS | wc -l` != ${#RUNNING_PODS[@]} ]]; then
if [[ `echo $ALL_PODS | wc -l | trim` != ${#RUNNING_PODS[@]} ]]; then
sleep 2
echo $fg[red]'Pods are not ready, wait...'$reset_color
continue