2026年6月10日(水) 4:42 Robert Elz <[email protected]>:
>   | $ PS4='+\[$\]-'
>   | $ set -x
>   | $ echo hello
>   | +$- echo hello
>   | hello
>
> If that's what you're trying to achieve,

No, that's not what we are trying to achieve. That is just an example
to illustrate the impact of the recent change in commit 1e9f5e10.

For the original background, you can reference the URL at the bottom
of the original post. In short, the request is related to a trick to
embed a literal backslash in PS0 (as a part of the 7-bit
representation of the C1 character, ST) in a way that it is not
affected by the Bash option `shopt -s promptvars'.

> If you want to output a bold - after a non-bold + then

No, this is also irrelevant to the present discussion.

> In PS4 the \[ \] are pointless, and should simply vanish

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.

> As I understand the bash rules, between the \[ and \] in prompts there
> are only supposed to be data which affects the display mode of the

The original cases follow that rule. Again, the top example is just a
reduced case. Also, we can make another example that satisfies your
condition while being affected by the change in 1e9f5e10. However, I
don't think providing an ``un-reduced'' case would be relevant in the
present discussion.

> From what I can tell (I don't actually use any of this) what bash is
> doing now, as described, is exactly what it should be doing (unless it

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'. You seem to support
pre-`promptvars' removal in the current devel branch, but it actually
only removes the embedded markers halfway. To remove those markers,
including the ones emitted by command substitutions of a prompt
framework, one needs to remove them after `promptvars' instead of
pre-`promptvars' removal.

> \[ and \] are not intended to be some kind
> of generic quoting chars in prompts,

Again, the above example is just a reduced case to illustrate the behavior.

> a simple \ already does that.

Unfortunately, no, when `shopt -s promptvars' is involved in Bash.

--
Koichi

Reply via email to