Re: PS0 vs. \[ \] followup
Koichi Murase <[email protected]> Mon, 15 Jun 2026 09:52:36 +0900
| Newsgroups | gmane.comp.shells.bash.bugs |
|---|---|
| Message-ID | <CAFLRLk9fpMEHvyP_W7v5MGb5nLgE8G5NDW7jKhn1O1HT_PJJ2A@mail.gmail.com> |
2026=E5=B9=B46=E6=9C=8812=E6=97=A5(=E9=87=91) 4:24 Chet Ramey <chet.ramey@c= ase.edu>: > On 6/9/26 6:07 PM, Koichi Murase wrote: > > > Yes, we agree that they should simply vanish. We are talking about the > > details of when they should vanish. Actually, the current behavior of > > the devel branch fails to properly remove \x01 and \x02 embedded in a > > command substitution, such as `$(prompt-framework git-status)'. In > > fact, prompt frameworks such as Starship embed \x01 and \x02 in their > > output to change colors and styles in the middle of their output. To > > remove \x01 and \x02 properly, they should be removed at the very last > > step, as we are requesting in the present thread. > > Are you saying that bash should remove 0x01 and 0x02 anywhere they appear > in a prompt string, even if they are not added behind the scenes as part > of processing \[ and \] before passing the prompt to readline? Yes? But isn't that the behavior of PS1? As far as I test the behavior, PS1=3D$'\1\e[1m\2foo\1\e[m\2 ' has the same effect as PS1=3D$'\[\e[1m\]foo\[\e[m\] ' which implies that \1\2 that didn't originate from \[\] are treated the same as the ones originating from \[\]. Also, in y.tab.c (decode_prompt_string), I don't seem to find any special handling of \1\2 to make it distinguishable from \1\2 originating from \[\]. > Why would it do that? For consistency with PS1. > > We are talking about the detailed behavior of `what it should be > > doing'. Both removing \[\] from the beginning and removing \x01\0x02 > > at the final step satisfy what you seem to request. You haven't > > explained why they should be removed before the `promptvars' > > processing instead of after `promptvars'. > > There is no `removing'. They are simply not added if bash can't tell that > the prompt will be passed to readline. As already replied to kre's reply, that's just terminology. Could you please interpret that =C2=ABremoving=C2=BB means that =C2=ABthe correspondi= ng substring is not included in the string passed to the next step of the processing=C2=BB? -- Koichi