Hi!
> Signed-off-by: Hangbin Liu <liuhang...@gmail.com>
> ---
>  testcases/lib/test.sh | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/testcases/lib/test.sh b/testcases/lib/test.sh
> index 1c9b126..4183512 100644
> --- a/testcases/lib/test.sh
> +++ b/testcases/lib/test.sh
> @@ -134,6 +134,26 @@ tst_check_cmds()
>       done
>  }
>  
> +# tst_retry "command" [times]
> +# try run command for specified times, default is 3.
> +# Function returns 0 if succeed in RETRIES times or the last retcode the cmd
> +# returned
> +tst_retry()
> +{
> +     local cmd="$1"
> +     local RETRIES=${2:-"3"}
> +     while [ $RETRIES -gt 0 ]; do
> +             eval "$cmd"
> +             ret=$?
> +             if [ $ret -eq 0 ]; then
> +                     break
> +             fi
> +             let RETRIES--

The let construct is bash specific, we have to do RETRIES=$((RETRIES-1))
to keep the code working in rest of the shells as well.

> +             sleep 1
> +     done
> +     return $ret
> +}

-- 
Cyril Hrubis
chru...@suse.cz

------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to