Package: dash
Version: 0.5.12-12
Severity: normal
Dear Maintainer,
POSIX.1-2024 describes the exit status of the return utility as follows:
https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/V3_chap02.html#return
SYNOPSIS
return [n]
EXIT STATUS
... If n is not specified, the result shall be as if n were specified with
the current value of the special parameter '?' ...
In most case, the return command works as expected in dash. For example:
$ f() { false; return; }
$ f; echo "$?"
1
but in the first list of the while/until loop, it does not work as expected.
For example:
f_while() {
while false; return; do
echo 'this line is never executed'
done
}
f_until() {
until false; return; do
echo 'this line is never executed'
done
}
f_while; echo "$?"
f_until; echo "$?"
gives:
0
0
As the behavior of a POSIX-compliant shell, I expect "return" to return the
exit status of the preceding command even in this case. Is the above actual
behavior in dash intentional?
Kind regards,
Takaaki