Thanks for the recipe involving only built-in commands, which made it easy for me to see the bug. I installed the attached patch and am marking the bug as fixed.