Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: $pipestatus broken?



Bart Schaefer wrote:
> On Dec 23, 11:49am, Frank Terbeck wrote:
> } Bart Schaefer wrote:
> } > With that loop, I get a single "1" 100% of the time unless I attach to
> } > the process with GDB, in which case it becomes random.
> } 
> } It's correct that this should output "0 0", though, right?
>
> Yes, I believe so.
>
> I *think* the problem is that the right-hand-side is a builtin and thus
> does not have an external process.  It's therefore possible for the
> left side to exit and be reaped before the right side is done, so the
> shell forgets that it is in a pipeline at all.

I think that's part of it. It appears to have to be a loop on the
right-hand-side, too, though. The following never fails for me:

% (repeat 100000; do : | :; print "${pipestatus[@]}"; done) | sort -u
0 0

...unless, of course, the loop just needs to be there to delay the RHS,
for the exit/reap to happen as you suggested.

Regards, Frank



Messages sorted by: Reverse Date, Date, Thread, Author