Feature request

2020-11-08 Thread Budi
Need feature on while's readily flag

$ i=;while ((i<5)) ;do let i++ ;echo $i ;done ;echo $?
1
2
3
4
5
0

$ i=7;while ((i<5)) ;do let i++ ;echo $i ;done ;echo $?
0

we need feature on while's ability to supply flag when it's up to the
end of loop block
Please fulfill this, it's really needed
Thanks much before.



Re: Feature request

2020-11-08 Thread Lawrence Velázquez
> On Nov 8, 2020, at 6:49 PM, Budi  wrote:
> 
> Need feature on while's readily flag
> 
> $ i=;while ((i<5)) ;do let i++ ;echo $i ;done ;echo $?
> 1
> 2
> 3
> 4
> 5
> 0
> 
> $ i=7;while ((i<5)) ;do let i++ ;echo $i ;done ;echo $?
> 0
> 
> we need feature on while's ability to supply flag when it's up to the
> end of loop block

It's not clear what you're asking for. Do you want while to exit
nonzero when it doesn't perform any loops?

> Please fulfill this, it's really needed

For what?

vq



Re: Feature request

2020-11-08 Thread Dale R. Worley
 writes:
>> On Nov 8, 2020, at 6:49 PM, Budi  wrote:
>> 
>> Need feature on while's readily flag
>> 
>> $ i=;while ((i<5)) ;do let i++ ;echo $i ;done ;echo $?
>> 1
>> 2
>> 3
>> 4
>> 5
>> 0
>> 
>> $ i=7;while ((i<5)) ;do let i++ ;echo $i ;done ;echo $?
>> 0
>> 
>> we need feature on while's ability to supply flag when it's up to the
>> end of loop block
>
> It's not clear what you're asking for. Do you want while to exit
> nonzero when it doesn't perform any loops?

I suspect what Budi wants is more explicit control of the exit value of
the while block.  Of course, as long as the block is executed at least
once, it is straightforward to control the exit value.  Compare these
two examples:

$ i=0;while ((i<5)) ;do let i++ ;echo $i; true ;done ;echo $?

$ i=0;while ((i<5)) ;do let i++ ;echo $i; false ;done ;echo $?

What cannot be controlled is the exit value if the block is not executed
i.e. if the initial evaluation of the condition is false.  In that case,
the exit value is always zero.

Dale