Re: "until continue" causes bash to exit.
On 07/19/2016 09:45 PM, Chet Ramey wrote: > On 7/19/16 7:15 PM, Dan Douglas wrote: >> Hi, I could reproduce this in all bash versions. >> >> bash -c 'set -x; until continue; do :; done; echo test1'; echo test2 >> + continue >> test2 >> >> I'm not actually sure whether this is supposed to work at all. Almost >> all shells do something strange when given continue in the first >> compound-list. E.g. ksh93 does like bash and exits, and zsh breaks >> out of the loop. > > It should probably print `test1' That's what I figured. Playing around with this test the current bash continues an outer loop if levels=1 while the "normal" ones (dash/mksh) do so at levels=2. I suppose technically a script that before would have continued the n+1th nested loop will now be off by one. (Not too likely such a script exists or they would have noticed this.) $ { bash /dev/fd/9; echo; } 9<<\EOF set -x; n=-1 levels=1 let 1 2>/dev/null || let() { IFS=, command eval test '$(($*))' -ne 0; } until echo 1 let n+=1 && break do until echo 2; continue "$levels" do : done echo 3 done EOF + n=-1 + levels=1 + let 1 + echo 1 1 + let n+=1 + echo 2 2 + continue 1 + echo 1 1 + let n+=1 + break signature.asc Description: OpenPGP digital signature
Re: "until continue" causes bash to exit.
On 7/19/16 7:15 PM, Dan Douglas wrote: > Hi, I could reproduce this in all bash versions. > > bash -c 'set -x; until continue; do :; done; echo test1'; echo test2 > + continue > test2 > > I'm not actually sure whether this is supposed to work at all. Almost > all shells do something strange when given continue in the first > compound-list. E.g. ksh93 does like bash and exits, and zsh breaks > out of the loop. It should probably print `test1', and I'll change bash to make it do that. `continue' just sets a flag saying how many loop levels to break, but it doesn't get reset if the loop test causes the loop to break. I imagine ksh93 does the same thing. dash and mksh go into an infinite loop. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/ signature.asc Description: OpenPGP digital signature
Re: "until continue" causes bash to exit.
On Wed, Jul 20, 2016 at 7:15 AM, Dan Douglaswrote: > Hi, I could reproduce this in all bash versions. > > bash -c 'set -x; until continue; do :; done; echo test1'; echo test2 > + continue > test2 > > I'm not actually sure whether this is supposed to work at all. Almost > all shells do something strange when given continue in the first > compound-list. E.g. ksh93 does like bash and exits, and zsh breaks > out of the loop. > I see nothing wrong using continue before `do`. I've used it a lot of times and I never had issues with it. It is useful when trying to imitate `do {} until ...`, or `do {} while ...`. However, I won't mind if it just skips checking `$?` when an explicit control command like `continue` is used since it's more sensible that way. Currently, `continue` is just synonymous to `break` when used in an `until` loop, and I find that counter-intuitive. Four others shells don't behave that way. -- konsolebox
"until continue" causes bash to exit.
Hi, I could reproduce this in all bash versions. bash -c 'set -x; until continue; do :; done; echo test1'; echo test2 + continue test2 I'm not actually sure whether this is supposed to work at all. Almost all shells do something strange when given continue in the first compound-list. E.g. ksh93 does like bash and exits, and zsh breaks out of the loop. signature.asc Description: OpenPGP digital signature