bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: while clause with two conditions does not execute when continue is u


From: Greg Wooledge
Subject: Re: while clause with two conditions does not execute when continue is used
Date: Wed, 21 Oct 2020 11:13:21 -0400
User-agent: Mutt/1.10.1 (2018-07-13)

On Wed, Oct 21, 2020 at 04:48:39PM +0200, rrd@beelaertsict.nl wrote:
> #!/bin/bash
> # test error in while clause
> #
> set -x
> up () {
>     i=$(($i+1))
>     [ $i -eq 5 ] && j=$(($j+1)) && i=0
> }

> while [ $i -ne 4 -o $j -ne 2 ]
> do
>     if [ $i -eq 3 ]
>     then
>       up && continue

If $i is 3, you call up.  up increments i, so $i is now 4.  Then it
runs [ $i -eq 5 ] which is false, so the function returns false.

Therefore, continue is never executed here.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]