bash: igncr shell option breaks my PS1 prompt

Gene Pavlovsky gene.pavlovsky@gmail.com
Sun Sep 4 09:11:00 GMT 2016


On 2 September 2016 at 16:32, Eric Blake <eblake@redhat.com> wrote:
> On 09/02/2016 06:52 AM, Gene Pavlovsky wrote:
>> Dear Eric Blake,
>>
>> Basically, I don't want to set `igncr` as system-wide shell option
>> (e.g. through SHELLOPTS).
>
> Don't use it, then.  I highly recommend avoiding 'igncr', because it
> exists only as a crutch.  The real solution is to fix your environment
> to be binary-clean, at which point you no longer need igncr. But I also
> understand that fixing an environment to be binary-clean can be
> expensive, so 'igncr' remains as the crutch.

Exactly, so I would really prefer to avoid crutches.

>> So, how do I keep an existing bash script, that uses `read` piped from
>> the output of a Windows console program that uses CRLF as newlines,
>> working, without modifying the script? I don't see how it's possible
>> with the current situation.

> By piping the output of the Windows program through d2u before handing
> it to 'read'.

The script in question (at the moment) is
[AutoMySQLBackup](https://sourceforge.net/projects/automysqlbackup/).
I didn't make it, I might want to update it when a new version comes
out. Having to add either "set -o igncr" or "| d2u" to the script
creates a maintainability problem - if I ever update it, I should
remember that I did that to this script, and do it again after an
update.
I could make a wrapper for mysql.exe, that pipes it's output through
d2u - which sounds like a bad crutch as well.
Worst thing is, I should spend time investigating why some (other)
script is failing in a non-obvious fashion. Looking through the code
to find out which Windows program it uses that should be piped through
d2u.

No matter how you look it at, the recent change to `read` might have
broken many scripts that were functioning before.
The solution you suggested means broken scripts should first be found,
then investigated, then some Cygwin-specific code added to them. That
sounds like a lot of work, and if the scripts in question are
third-party, a maintainability problem. At the moment, I'm forced to
use an older version of bash due to this particular issue.

Do you see a better solution here?

Regards,
--Gene

--
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



More information about the Cygwin mailing list