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

Re: $pipestatus broken?



On Dec 23, 11:49am, Frank Terbeck wrote:
} Subject: Re: $pipestatus broken?
}
} 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 get correct behavior if the right-side loop is in a subshell.  In a
curious twist, if the loop is in { braces } , then $pipstatus is a
single 0 instead of a single 1.  This may be a clue to where/how the
pipestatus internals are being improperly reset, but I have yet to
figure it out.



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