Bug in bash? different from ksh, at any rate...
Can anybody explain this difference between the behavior of bash and
ksh?
When reading the man page, I would expect both of them to have the
behavior exhibited by ksh.
Why does bash seem to treat "return" like a single level "break" in
this context?
The "echo "$AA" | while read" is important context. If I change it to
"for i in 0 1", return does as expected.
If it's any help, changing "return" to "break 2" doesn't help. with
bash, it still gives "1 1 1 1"
while ksh still gives "1"
I wonder if it has anything to do with "while read" causing a subshell
to be created, and bash getting confused about the "return" inside of
a subshell. If so, it's a bug in bash that ksh gets right, so it
ought to be fixable.
ADVthanksANCE
Rick
----------- example of strange behavior below -----------
:~$ cat /tmp/testit
function strange {
for j in 0 1 2 3
do
AA=' 1
2'
echo "$AA" | while read i
do
echo "$i"
return
done
done
}
echo $(strange)
:~$ bash /tmp/testit
1 1 1 1
:~$ ksh /tmp/testit
1
----------- example of strange behavior above -----------
Reply to: