From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2712 invoked by alias); 23 Dec 2011 22:17:30 -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: 30053 Received: (qmail 5401 invoked from network); 23 Dec 2011 22:17:28 -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, SPF_HELO_PASS autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at bewatermyfriend.org does not designate permitted sender hosts) From: Frank Terbeck To: zsh-workers@zsh.org Subject: Re: $pipestatus broken? In-Reply-To: <111223133128.ZM17298@torch.brasslantern.com> (Bart Schaefer's message of "Fri, 23 Dec 2011 13:31:28 -0800") References: <87borgzkap.fsf@ft.bewatermyfriend.org> <877h24zj69.fsf@ft.bewatermyfriend.org> <111210065833.ZM6198@torch.brasslantern.com> <877h1nwojx.fsf@ft.bewatermyfriend.org> <111223133128.ZM17298@torch.brasslantern.com> User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.91 (gnu/linux) Date: Fri, 23 Dec 2011 23:11:29 +0100 Message-ID: <87hb0rueem.fsf@ft.bewatermyfriend.org> MIME-Version: 1.0 Content-Type: text/plain X-Df-Sender: NDMwNDQ0 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