Re: [PATCH v4 1/5] t9300: factor out portable "head -c" replacement
- From
Jeff King <peff@peff.net>
- Date
- Jul 1, 2016, 18:01 UTC
- Message-ID
- <20160701180142.GC16235@sigill.intra.peff.net>
- In-Reply-To
- <xmqqd1mxz30m.fsf@gitster.mtv.corp.google.com>
On Fri, Jul 01, 2016 at 10:23:05AM -0700, Junio C Hamano wrote:
Show 12 quoted lines
> Jeff King <peff@peff.net> writes: > > > 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. > > I'd rotate the above by three words ;-). > > It is sometimes useful to be able to read > exactly N bytes from a pipe. Doing this portably turns out > to be surprisingly difficult > in shell scripts.
Yeah, I'd very much agree with that (feel free to mark it up as you apply).
Show 8 quoted lines
> > - "dd bs=1 count=$n" fixes the partial read problem (all > > reads are 1-byte, so there can be no partial response). > > It does make a lot of write() calls, but for our tests > > that's unlikely to matter. > > It makes me wonder if it helps to use different ibs and obs if many > writes bother you, but because this patch moves us away from dd, > that is a moot point.
Actually, I just mis-spoke (mis-wrote?). I meant to say that it makes a lot of read() calls. (It probably also makes a lot of write() calls, but that is beside the point).
-Peff