On Thu, Oct 20, 2016 at 11:32 PM, Martijn Dekker <mart...@inlv.org> wrote: > #! /usr/local/bin/bash > insubshell() { > return "$((BASHPID=$$))" > # ^ fatal typo > } > for ((i=0; i<10000; i++)); do insubshell; done > echo $i > insubshell || echo ok > echo continuing > > The output of this script on my copy of bash-4.4.0 is consistently: > > | 0 > | continuing > > Clearly, that 0 should be 10000. The 'insubshell' function somehow > manages to interrupt the 'for' loop.
It's not so much the for loop. See, $ BASHPID= echo k bash: BASHPID: readonly variable k $ BASHPID=; echo k $ echo k k See the second k is not printed. bash simply aborts this command. In your case, the for compound command. The bug probably is very clear to Chet already.