From owner-freebsd-hackers@FreeBSD.ORG Sat Jun 5 21:37:32 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 994B4106567C; Sat, 5 Jun 2010 21:37:32 +0000 (UTC) (envelope-from bakul@bitblocks.com) Received: from mail.bitblocks.com (bitblocks.com [64.142.15.60]) by mx1.freebsd.org (Postfix) with ESMTP id 7BD858FC19; Sat, 5 Jun 2010 21:37:32 +0000 (UTC) Received: from bitblocks.com (localhost.bitblocks.com [127.0.0.1]) by mail.bitblocks.com (Postfix) with ESMTP id 816035B30; Sat, 5 Jun 2010 14:37:31 -0700 (PDT) To: Doug Barton In-reply-to: Your message of "Sat, 05 Jun 2010 14:02:16 PDT." <4C0ABB58.6030009@FreeBSD.org> References: <20100605201242.C79345B52@mail.bitblocks.com> <4C0AB448.2040104@FreeBSD.org> <20100605204845.6E56B5B52@mail.bitblocks.com> <4C0ABB58.6030009@FreeBSD.org> Comments: In-reply-to Doug Barton message dated "Sat, 05 Jun 2010 14:02:16 -0700." Date: Sat, 05 Jun 2010 14:37:31 -0700 From: Bakul Shah Message-Id: <20100605213731.816035B30@mail.bitblocks.com> Cc: freebsd-hackers@freebsd.org Subject: Re: head behaviour X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jun 2010 21:37:32 -0000 On Sat, 05 Jun 2010 14:02:16 PDT Doug Barton wrote: > On 06/05/10 13:48, Bakul Shah wrote: > > Without running the following can you guess its output? > > > > $ look '' | (head -2; head -2) > > Again, it's not clear to me what you expect is going to happen with the > second 'head -2' there. I agree that the actual output of your example > is wacky and unexpected, but what I'm trying to get you say is what YOU > think should happen. The examples that you pasted in your previous post > did not and could not do what you said you wanted them to do, so I don't > quite understand what the bug is. There is no bug per se. What I am saying that it would be *less surprising* if $ look '' | (head -2; head -2) behaved the same as $ look '' | head -4 [And yes, I would use head -4 if I wanted four lines but the example was to illustrate the issue that head buffers more than it needs to]. It would be less surprising and more useful if $ ps | (head -1; grep ssh) showed PID TT STAT TIME COMMAND The change in head behaviour I am suggesting wouldn't break anything that already works but make it more useful for what you call 'wacky commands lines'! > Put more simply, if you generate wacky command lines you should not be > surprised when they produce wacky results. :) I didn't realize that use of ;(|) constitutes wackiness :-) They are simply exercising the power of shell! We have used these commands for so long that we take them for granted and we learn to avoid their use in such ways. When Rob Warnock first mentioned this, my initial reaction was the same as yours. But thinking more about it, I felt head can be made more useful with this change and felt it was worth bringing it to people's attention. But we can let it rest.