On Fri, Jun 24, 2016 at 03:07:44PM -0400, Jeff King wrote: > > "dd bs=1 count=4096" is hopefully more portable. > > Hmm. I always wonder whether dd is actually very portable, but we do use > it already, at least. > > Perhaps the perl monstrosity in t9300 could be replaced with that, too. Hrm. So I wrote a patch for t9300 for this. But I wanted to flip the order to: dd bs=4096 count=1 because otherwise, dd will call read() 4096 times, for 1 byte each. But it's not safe to do that on a pipe. For example: { echo 1 sleep 1 echo 2 } | dd bs=4 count=1 will copy only 2 bytes. So it's racily wrong, depending on how the writer feeds the data to write(). The 1-byte reads do work (assuming blocking descriptors and that dd restarts a read after a signal, which mine seems to). But yuck. The difference in time between the two is measurable on my system, but it's only a few milliseconds (for 4096 bytes). So maybe it's not worth worrying about (though as a general technique, it does make me worry that it's easy to get wrong in a way that will fail racily). -Peff -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html