dash 0.5.9: break and continue bug
Hi, I've noticed 0.5.9 does ignore break and continue statements, here is simple reproducer:
one() {
echo " one"
break
}
two() {
echo " two"
}
for i in 1 2
do
echo "loop $i:"
one
twodone
dash-0.5.9:
$ dash dash-break-test loop 1: one two loop 2: one two
dash-0.5.8-4.fc24.x86_64:
$ dash dash-break-test loop 1: one
HTH, Z.
Quoted 30 lines · Zdenek Kaspar
Hi, I've noticed 0.5.9 does ignore break and continue statements, here is simple reproducer:
one(){
echo " one"
break
}
two(){
echo " two"
}for i in 1 2
doecho "loop $i:" one twodone
dash-0.5.9:
$ dash dash-break-test loop 1: one two loop 2: one two
Quoted 4 lines
dash-0.5.8-4.fc24.x86_64:
$ dash dash-break-test loop 1: one
break and continue now need to appear in the loop directly, they cannot be wrapped in a function any more. Although this is a visible change in behaviour, it is intentional:
<https://www.mail-archive.com/dash%40vger.kernel.org/msg00929.html>
The standard is a bit unclear on how break and continue are meant to behave in these situations, as it refers to the "enclosing loop" without defining what counts and doesn't count as the enclosing loop, but the next version of the standard will make it clear that your script is not required to behave the way you expect:
<http://austingroupbugs.net/view.php?id=842>
That said, shells are still allowed to treat your script the way you expect.
Quoted 1 line
HTH, Z.
Quoted 48 lines · Harald van Dijk
Quoted 30 lines · Zdenek Kaspar
Hi, I've noticed 0.5.9 does ignore break and continue statements, here is simple reproducer:
one(){
echo " one"
break
}
two(){
echo " two"
}for i in 1 2
doecho "loop $i:" one twodone
dash-0.5.9:
$ dash dash-break-test loop 1: one two loop 2: one twoQuoted 4 lines
dash-0.5.8-4.fc24.x86_64:
$ dash dash-break-test loop 1: onebreak and continue now need to appear in the loop directly, they cannot be wrapped in a function any more. Although this is a visible change in behaviour, it is intentional:
<https://www.mail-archive.com/dash%40vger.kernel.org/msg00929.html>The standard is a bit unclear on how break and continue are meant to behave in these situations, as it refers to the "enclosing loop" without defining what counts and doesn't count as the enclosing loop, but the next version of the standard will make it clear that your script is not required to behave the way you expect:
<http://austingroupbugs.net/view.php?id=842>
Quoted 4 lines
That said, shells are still allowed to treat your script the way you expect.
Quoted 1 line
HTH, Z.
Kinda sucks it does not abort execution completely and write some error message then, because this can do some damage...
Anyway, thanks Harald for pointing me to changed SPEC where this (new) behaviour is explained.
THX, Z.