2026年6月12日(金) 4:24 Chet Ramey <[email protected]>: > 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=$'\1\e[1m\2foo\1\e[m\2 ' has the same effect as PS1=$'\[\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 «removing» means that «the corresponding substring is not included in the string passed to the next step of the processing»? -- Koichi
