bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read builtin ignores a byte after \r in bash-4.3-p42 in Cygwin


From: Eric Blake
Subject: Re: read builtin ignores a byte after \r in bash-4.3-p42 in Cygwin
Date: Fri, 5 Aug 2016 22:02:16 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 08/05/2016 04:31 PM, Eric Blake wrote:
> On 03/20/2016 11:49 AM, Chet Ramey wrote:
>> On 3/20/16 12:54 AM, Жанна Целых wrote:
>>
>>> uname output: CYGWIN_NT-6.1 microsoft-win7 2.4.1(0.293/5/3) 2016-01-24
>>> 11:24 i686 Cygwin
>>> Machine Type: i686-pc-cygwin
>>>
>>> Bash Version: 4.3
>>> Patch Level: 42
>>> Release Status: release
>>>
>>> Description:
>>>         In bash-4.3-p42 from Cygwin read builtin ignores some bytes after
>>> CR-byte.
>>
>> It may be the setmode() call in the read builtin, but that's been there
>> forever.
>>
>> I don't use cygwin or test on it.  You'll probably have better luck filing
>> a bug report with the cygwin folks.
> 
> I'm testing what happens if the setmode() call is removed in my next
> build of bash for cygwin; I can't figure out why text mode would be
> desirable in the first place, but even if it is desirable, it should
> only eat \r immediately before \n, not \r before other bytes.  This may
> be stale leftover code from years ago that doesn't make sense to keep
> around.

Indeed, it is the setmode() call that is wrong, and which should be
deleted. The intent of O_TEXT is that if you have the sequence \r\n,
then \r is eaten; but when you have \r followed by something else, then
the \r should be preserved; but something is borked in the way bash uses
stdio such that the non-\n after the \r is getting eaten instead.  But
in general, you WANT 'read' to be binary, not text-based, and my current
build of bash for cygwin rips out the setmode() call entirely.

In the cygwin build of bash, I've added 'set -o igncr', which controls
whether bash ignores ALL \r on input sources (script parsing, command
substitution, read builtin), which has been in use for many years now.
Maybe I should find the time to clean up the patches and post them for
upstream inclusion, to wipe out old broken setmode() cruft like this
that downstream cygwin no longer wants to use, and replace it with the
solution that has been working well for cygwin users.  But I'm too late
for 4.4...

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]