That return only returns from the sub-shell in which while is run - you're running while via pipe |.
return
while
|
Remove echo | and it will behave as you expected.
echo |
PS: man bash or help return are your friends.
man bash
help return
1.4m articles
1.4m replys
5 comments
57.0k users