public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: cyg Simple <cygsimple@gmail.com>
To: cygwin@cygwin.com
Subject: Re: Script broken after updating bash to 4.3.46-7?
Date: Wed, 31 Aug 2016 10:16:00 -0000	[thread overview]
Message-ID: <7314ffba-a927-f565-e38e-7454d6c2ef0f@gmail.com> (raw)
In-Reply-To: <1de2efdc-b26c-4914-580c-1a640d0a46fd@redhat.com>

On 8/30/2016 1:38 PM, Eric Blake wrote:
> On 08/30/2016 12:04 PM, cyg Simple wrote:
>> On 8/29/2016 2:30 PM, Eric Blake wrote:
>>>
>>> Simplest fix:
>>>
>>> read ... < <(mysql ... | dos2unix)
>>>
>>
>> This will break when the data returned by mysql is supposed to contain \r.
>>
>>> There. Now you aren't feeding \r to read in the first place.
>>>
>>
>> But you might want to feed \r to read.  It isn't a fix, it is a
>> potential work around dependent on the data set results.  If a read that
>> is supposed to be reading binary data doesn't pass all of the data to
>> the routine then it is broken.
> 
> Now we're talking past each other.
> 
> That's what the recent bash fixed.  'read' in bash 3.2.42-4 was broken -
> it corrupted binary data, with no recourse, by eating \r (and worse, by
> sometimes eating the byte after \r).  'read' in bash 3.2.46-7 is fixed -
> by default it is strictly binary (all bytes are read as-is, including
> \r), but can also be switched to text mode (using 'igncr', all \r are
> ignored).  If you want to preserve mid-line \r but treat line endings of
> \r\n as a single byte, then leave binary mode on and strip the line
> endings via a separate tool like d2u (note, however, that it is very
> rare to have data where mid-line \r is important but line-ending \r\n
> should be treated as plain \n).
> 
> I strongly think that using igncr is a crutch, and you normally
> shouldn't use it; particularly not if you want to be portable to other
> platforms.  Instead, massaging your data through d2u is a great way to
> be portable.  But sometimes the ease of ignoring ALL \r is easier than
> worrying about portability, so I keep the 'igncr' code in Cygwin.
> 
> And it is only because the OP tried using 'igncr' in the first place
> (whether or not it was actually needed) that we have now flushed out the
> existence of a latent bug in the 'igncr' implementation that interacts
> weirdly with $()\n in PS1.  On that front, I'm still hoping to find time
> to debug and/or for someone to post a patch.  But whether PS1 behaves
> weirdly under 'igncr' is orthogonal to my suggestion above - using
> 'mysql|d2u' is a great way to avoid the need to worry about 'igncr'.
> 

Thank you for the retort Eric.  Happy to know that it is fixed which in
the back of my mind I knew already.  I can imagine data such as full
message email or a small document data containing \r\n as valid data in
the database field and if you use a line ending conversion utility you
might loose that data.

-- 
cyg Simple

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2016-08-30 20:56 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-27 10:28 Gene Pavlovsky
2016-08-27 11:25 ` Gene Pavlovsky
2016-08-27 17:24   ` Andrey Repin
2016-08-28 10:19     ` Gene Pavlovsky
2016-08-29 13:28       ` Nellis, Kenneth
2016-08-29 14:05     ` cyg Simple
2016-08-30  3:21 ` Eric Blake
2016-08-30 18:21   ` cyg Simple
2016-08-30 18:32     ` Eric Blake
2016-08-31 10:16       ` cyg Simple [this message]
2016-09-04  9:38         ` Gene Pavlovsky
2016-09-04 17:37           ` Lee
2016-09-05 23:37             ` Gene Pavlovsky
2016-09-06 13:15           ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7314ffba-a927-f565-e38e-7454d6c2ef0f@gmail.com \
    --to=cygsimple@gmail.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).