From d25cec232053467d9c5ce10a5262cce52324fbab Mon Sep 17 00:00:00 2001 From: katherine Date: Sat, 22 Dec 2018 14:00:24 -0700 Subject: clean wait-anim --- .config/init/helpers | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to '.config/init/helpers') diff --git a/.config/init/helpers b/.config/init/helpers index 81859ec..37ae17a 100644 --- a/.config/init/helpers +++ b/.config/init/helpers @@ -160,16 +160,21 @@ wait-anim() { 6) frames=('O' 'o' '.' 'o') ;; esac - (while 2>/dev/null kill -0 $1; do + local rval + + { + wait $1 + rval=$? + echo "done" + } | while true; do [[ -z $curframe ]] && curframe=0 printf "\e[G\e[K|\e[1;32m${frames[$(($curframe + 1))]}\e[0m| $colour$message...\e[0m" curframe=$(( ($curframe + 1) % $#frames )) - sleep .2 - done) & - - wait $1 - local r=$? - [[ $r ]] && printf "\e[G\e[K\e[31m$message... failed!\e[0m\n" \ - || printf "\e[G\e[K\e[32m$message... done!\e[0m\n" - return $r + read -t 0.2 && break + done + + [[ $rval -eq 0 ]] && printf "\e[G\e[K\e[32m$message... done!\e[0m\n" \ + || printf "\e[G\e[K\e[31m$message... failed!\e[0m\n" + + return $rval } -- cgit v1.2.3