Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Aug 2010 16:54:44 -0400
From:      jhell <jhell@DataIX.net>
To:        Alexander Best <arundel@freebsd.org>
Cc:        Anonymous <swell.k@gmail.com>, freebsd-hackers@freebsd.org
Subject:   Re: tiny patch to prevent head from closing pipes
Message-ID:  <4C7AC914.1080804@DataIX.net>
In-Reply-To: <20100828160129.GA88842@freebsd.org>
References:  <20100828141625.GA69240@freebsd.org> <86aao694tm.fsf@gmail.com> <20100828160129.GA88842@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 08/28/2010 12:01, Alexander Best wrote:
> On Sat Aug 28 10, Anonymous wrote:
>> Alexander Best <arundel@freebsd.org> 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4C7AC914.1080804>