From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24074 invoked by alias); 23 Dec 2011 21:31:48 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30052 Received: (qmail 18564 invoked from network); 23 Dec 2011 21:31:47 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <111223133128.ZM17298@torch.brasslantern.com> Date: Fri, 23 Dec 2011 13:31:28 -0800 In-reply-to: <877h1nwojx.fsf@ft.bewatermyfriend.org> Comments: In reply to Frank Terbeck "Re: $pipestatus broken?" (Dec 23, 11:49am) References: <87borgzkap.fsf@ft.bewatermyfriend.org> <877h24zj69.fsf@ft.bewatermyfriend.org> <111210065833.ZM6198@torch.brasslantern.com> <877h1nwojx.fsf@ft.bewatermyfriend.org> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: $pipestatus broken? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii 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.