This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: bash: igncr shell option breaks my PS1 prompt

On 08/28/2016 03:20 PM, Gene Pavlovsky wrote:
> Re-posting a reply I got from Henri (aka Houder)
> His letter follows:
> Hi Gene,
> Reread your entry to the mailing list ...
>> Apparently the latest bash in Cygwin modified the read builtin to use
>> Cygwin-specific shell option igncr to control ignoring \r characters
>> in the input (still not clear if that ignores \r\n sequences, or \r
>> followed by anything else will be also ignored).

If the igncr shell option (currently Cygwin-specific, but Chet says that
he is amenable to reviewing it for upstream inclusion in 4.5 once 4.4 is
released any day now) is enabled, then it eats ALL \r, regardless of
context.  In other words, it ignores all carriage returns, as per the name.

>> I considered enabling the `igncr` option everywhere, by declaring a
>> SHELLOPTS=igncr Windows environment variable, however immediately it
>> created an issue with my two-line PS1 prompt, which contains \n.
>> # PS1='\e[1;30m\D{%T}\e[m$(test \j -ne 0 && echo "
>> \e[1;37mj:\j\e[m")${STY:+ \e[1;32m${STY%%.*}\e[m} \e[1;33m\w\e[m\n# '
>> 14:32:22 /usr/local/bin
>> # set -o igncr
>> bash: command substitution: line 1: syntax error near unexpected token `)'
>> bash: command substitution: line 1: `test 0 -ne 0 && echo " j:0")'
>> 14:32:24{STY:+ } /usr/local/bin
>> # set +o igncr
>> 14:32:26 /usr/local/bin
>> #
>> What's wrong with this? It works fine on a Linux box.
>> I'm considering rolling back bash until I can figure this out.

Eating \n is NOT supposed to happen, so it may be that some other bug is
still present in the code.  At least you have given me a test case, so I
can try and reproduce it, and upload a version of bash that does not
have the problem if I can find where the bug actually lives.

But it seems like \n handling in PS1 is independent of any change in
handing in the 'read' builtin.  As evidence, I ran the following test
using the older bash-4.3.42-4 build:

$ bash-4.3.42-4
$ set -o igncr
$ PS1='$(date)\n# '
bash: command substitution: line 1: syntax error near unexpected token ')'
bash: command substitution: line 1: `date)'

$ exit

So you have uncovered a latent problem, unrelated to the recent igncr
fixes, but which is indeed tied to the overall igncr patches, and which
you had no reason to trip over until the igncr change to 'read' changed
your desire to use igncr.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library

Attachment: signature.asc
Description: OpenPGP digital signature

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]