2026年5月15日(金) 20:35 Egmont Koblinger <[email protected]>:
> Actually, in bash-5.3.9, PS0 does not support \[ and \]. If these are
> present in its value, their corresponding raw 0x01 and 0x02 bytes do get
> printed, rather than getting eliminated.
The statement that "PS0 does not support \[\]" may be controversial
[^1], but I agree that it is reasonable to remove \x01 and \x02 at the
final step of printing PS0.
I think ${var@P} should also remove \x01 and \x02 at the final step.
[^1]: PS0 does support \[\] somehow by converting them to Bash's
internal markers \0x01 and \x02, but the behavior is incomplete and
undesired. In the case of PS[124], Bash or Readline finally removes
those markers before printing the prompt to the terminal. However,
Bash directly outputs PS0 to the terminal without removing \x01 and
\x02. In this sense, the support is incomplete.
--
Koichi