|
From: | Paul Eggert |
Subject: | bug#21558: checking for a binary file is not deterministic |
Date: | Fri, 25 Sep 2015 12:17:57 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
On 09/25/2015 11:54 AM, Benno Schulenberg wrote:
On Fri, Sep 25, 2015, at 20:02, Paul Eggert wrote:Thanks for the bug report. This appears to be basically the same as Bug#20526.Well, not quite. That grep will see misencoded files as binary data, I understand. But what perplexed me is that grep would *sometimes* see the piped data as binary, and sometimes not. How is this possible?
Grep reads the first buffer out of the pipe and decides based on that buffer whether the input is binary. Due to timing issues the pipe's first buffer may contain more or fewer bytes, depending on the run. The change proposed for Bug#20526 would change grep so that it uses a deterministic algorithm, independent of the number of bytes it happens to get in the first input buffer.
If I understand it correctly, it would mean that in my example the piped data would never be classified as binary because the first grep will never output any of the misencoded bytes. Right?
Yes, that's the idea.
[Prev in Thread] | Current Thread | [Next in Thread] |