bug-bash
[Top][All Lists]
Advanced

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

Re: "until continue" causes bash to exit.


From: Dan Douglas
Subject: Re: "until continue" causes bash to exit.
Date: Wed, 20 Jul 2016 01:25:35 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1

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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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