On Tue, Feb 21, 2017 at 03:11:22PM +0100, Florian Mayer wrote: > >What does it do? > It behaves like the p-operation on unary Sys-V semaphores.
OK, without digging any further into this morass, and without trying to guess whether you've found a bug in bash or in your own tool, can I just leave this here on the nightstand? http://mywiki.wooledge.org/BashFAQ/045 I can't even try to guess what problem you are actually attempting to solve here, but it looks like you're making things about 5 times as complicated as they should be. If the problem is *inherently* this complex, then you shouldn't be solving it with a bash (or zsh) script.