bug-bash
[Top][All Lists]
Advanced

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

Ill positioned 'until' keyword


From: Peng Yu
Subject: Ill positioned 'until' keyword
Date: Wed, 14 Dec 2011 17:47:24 -0600

Hi,

I looks a little wired why 'until' is the way it is now. According to
the manual until is before the do-done block.

until test-commands; do consequent-commands; done

A common design of until in other language is that it allows the loop
body be executed at least once and test the condition at the end of
the run of the first time. It seems that a better of bash should also
follow the practice. If I understand it correctly, the above is exact
the same as the following, in which case the do done block can be
executed zero time. Because of this, I think that the current 'until'
is not necessary, and probably better to change its definition so that
it allows the execution of the loop at least once.

while ! test-commands; do consequent-commands; done


In short, I'd expect the following code echo 9 (not working with the
current bash).

COUNTER=9
do
             echo COUNTER $COUNTER
             let COUNTER-=1
done
until [  $COUNTER -lt 10 ];


I'd like to hear for what reason 'until' is designed in the way it is
now. Shall we considered to at least allow an option in bash to change
it meaning to the one I propose (or adding a different command, like
until2, for what I proposed), which give us time to let the orignal
until usage dies out.

-- 
Regards,
Peng



reply via email to

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