From: Ken Takata <ktakata65536@gmail.com>
To: cygwin@cygwin.com
Subject: bash: '\n' after command substitution in $PS1 causes errors when igncr is set
Date: Thu, 23 May 2024 13:16:46 +0900 [thread overview]
Message-ID: <CAKNHtdksoxgSjniZJpxYFK+kVCv-4dh7=fSi0wHMLVYdvoTHaQ@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 752 bytes --]
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
[-- Attachment #2: bash-5.2-cygwin-fix-igncr.patch --]
[-- Type: application/octet-stream, Size: 534 bytes --]
--- a/parse.y
+++ b/parse.y
@@ -1684,7 +1684,16 @@
into account, e.g., $(...\n) */
xchars = shell_input_line_len - shell_input_line_index;
if (bash_input.location.string[-1] == '\n')
- xchars++;
+ {
+ xchars++;
+#ifdef __CYGWIN__
+ {
+ extern int igncr;
+ if (igncr && bash_input.location.string[-2] == '\r')
+ xchars++;
+ }
+#endif
+ }
/* XXX - how to reflect bash_input.location.string back to string passed to
parse_and_execute or xparse_dolparen? xparse_dolparen needs to know how
reply other threads:[~2024-05-23 4:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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='CAKNHtdksoxgSjniZJpxYFK+kVCv-4dh7=fSi0wHMLVYdvoTHaQ@mail.gmail.com' \
--to=ktakata65536@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).