From owner-freebsd-hackers@FreeBSD.ORG Sun Aug 29 20:54:49 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 11FC01065696; Sun, 29 Aug 2010 20:54:49 +0000 (UTC) (envelope-from jhellenthal@gmail.com) Received: from mail-gx0-f182.google.com (mail-gx0-f182.google.com [209.85.161.182]) by mx1.freebsd.org (Postfix) with ESMTP id 94BEC8FC08; Sun, 29 Aug 2010 20:54:48 +0000 (UTC) Received: by gxk24 with SMTP id 24so2044888gxk.13 for ; Sun, 29 Aug 2010 13:54:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :x-enigmail-version:content-type:content-transfer-encoding; bh=vDtuy9lSvo7qKwCOCRl1NL1ml4rdosvTcPya3zLVBpc=; b=FVBujEugRdybB/M8xbuHApj/gWlaQsnAC/jvtiaJVoJwO8vWLzxGIEdDUabiDarFJA wxvqc25bFYi1GzgIeV44Wpk/ZNmPnRmLQnPI40jBnid1tTrOTJm4p328bfBLzL1XUv+S /dPLeumLevpzIOMLlHg7FW2K2BFl1m8ZVhNmA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=ItXBYoxx3kegX6THKzuxmrwPtVp6/u/IYpBQFZDKDF/qjX3LxhAgWdw7t3rQKOZCFL SHCERisKz1JB6/ngiwVMQ8RVIr6QvESOGp9y5GAiNlndEv4SNwdQV0pQ6d8jAbss6lQq ZuuBst56mIzocKtAqED4OLa9PDjtbsyN1ckzI= Received: by 10.90.98.4 with SMTP id v4mr3124572agb.58.1283115287175; Sun, 29 Aug 2010 13:54:47 -0700 (PDT) Received: from centel.dataix.local ([99.181.137.20]) by mx.google.com with ESMTPS id e8sm6572965ibb.8.2010.08.29.13.54.45 (version=SSLv3 cipher=RC4-MD5); Sun, 29 Aug 2010 13:54:46 -0700 (PDT) Sender: "J. Hellenthal" Message-ID: <4C7AC914.1080804@DataIX.net> Date: Sun, 29 Aug 2010 16:54:44 -0400 From: jhell User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.8) Gecko/20100806 Lightning/1.0b1 Thunderbird MIME-Version: 1.0 To: Alexander Best References: <20100828141625.GA69240@freebsd.org> <86aao694tm.fsf@gmail.com> <20100828160129.GA88842@freebsd.org> In-Reply-To: <20100828160129.GA88842@freebsd.org> X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Anonymous , freebsd-hackers@freebsd.org Subject: Re: tiny patch to prevent head from closing pipes 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: Sun, 29 Aug 2010 20:54:49 -0000 On 08/28/2010 12:01, Alexander Best wrote: > On Sat Aug 28 10, Anonymous wrote: >> Alexander Best writes: >> >>> hi there, >>> >>> i just had subversion complain about a broken pipe while piping its output >>> through awk straight to head [1]. i decided to add a switch to head which will >>> tell it to never close a pipe unless the input has stopped [2]. >> >> You can do same with sh(1), e.g. >> >> $ svn log | (IFS=; while read li; do [ $((i+=1)) -le 10 ] && echo "$li"; done) >> >> versus >> >> $ svn log | (IFS=; while read li && [ $((i+=1)) -le 10 ]; do echo "$li"; done) >> ... >> svn: Write error: Broken pipe >> >> >> But I think subversion should >> >>> there's probably a much more efficient way of discarding the input without >>> closing the pipe unless the input ceased. it's just a 5 minute hack in order to >>> see if people find the idea useful or not. ;) >> >> Can you give an example of usefulness that does not involve subversion? > > no, but this should be valid for all applications which return an error if the > pipe gets closed by the receiving end. > > of course it's possible to implement the features to head i added in form of a > sh(1) script. i understand that your point is, that there is already a way of > keeping the pipe open and that the unix philosophy states that no two programs > should share the same functionality. > > on the other hand you don't really need head and tail at all then, because > their functionality could also be implemented in form of a script. ;) i hope > you get my point. > > cheers. > alex > No offense but patching this would be honoring bad scripting and encouraging such things to happen more often. If you catch my drift. Regards, -- jhell,v