bash: '\n' after command substitution in $PS1 causes errors when igncr is set

Ken Takata ktakata65536@gmail.com
Thu May 23 04:16:46 GMT 2024


Hello all,

I originally reported this issue to the msys2 team:
https://github.com/msys2/MSYS2-packages/issues/1839
https://github.com/msys2/MSYS2-packages/pull/4477
But I find that this issue is coming from Cygwin Bash, so I'm reporting
here.

When I use \n after command substitution in $PS1, it causes syntax errors
when the igncr option is set:
```
$ set -o igncr
$ PS1='$(date)\n\$ '
-bash: command substitution: line 1: syntax error near unexpected token `)'
-bash: command substitution: line 1: `date)'
```
(Confirmed with bash-5.2.21-1)

I found an issue in rewind_input_string() in parse.y. It didn't take care
of '\r'.
Please find the attached patch to fix it.
Could you consider merging this into bash-5.2-cygwin.patch?

Regards,
Ken Takata
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bash-5.2-cygwin-fix-igncr.patch
Type: application/octet-stream
Size: 534 bytes
Desc: not available
URL: <https://cygwin.com/pipermail/cygwin/attachments/20240523/18625a6e/attachment.obj>


More information about the Cygwin mailing list