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..60a9984 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=$((RETRIES-1))

The let keyword is known only by bash. So the whole line should just be
the RETRIES=$((RETRIES-1)).

Have a look at https://wiki.ubuntu.com/DashAsBinSh#let

> +             sleep 1
> +     done
> +     return $ret
> +}
> +
>  # tst_timeout "command arg1 arg2 ..." timeout
>  # Runs command for specified timeout (in seconds).
>  # Function returns retcode of command or 1 if arguments are invalid.
> -- 
> 1.9.3
> 

-- 
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