From: Eric Sunshine Date: Fri, 01 Jul 2016 04:45:10 GMT Subject: Re: [PATCH v4 1/5] t9300: factor out portable "head -c" replacement Message-ID: In-Reply-To: <20160630090753.GA17463@sigill.intra.peff.net> On Thursday, June 30, 2016, Jeff King wrote: > In shell scripts it is sometimes useful to be able to read > exactly N bytes from a pipe. Doing this portably turns out > to be surprisingly difficult. > > We want a solution that: > > - is portable > > - never reads more than N bytes due to buffering (which > would mean those bytes are not available to the next > program to read from the same pipe) > > - handles partial reads by looping until N bytes or read s/or/are/ > (or we see EOF)