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'. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org