2026年6月8日(月) 22:39 Chet Ramey <[email protected]>: > The behavior of PS0 is the same as PS4
PS4 behaved differently before the latest commit in the devel branch was applied. In the latest commit 1e9f5e10, $ PS4='+\[$\]-' $ set -x $ echo hello +himBHs echo hello hello However, in the previous commit 2d4ba0c and all past Bash versions 3.0..5.3 (note that, in the following result, there are characters \x01 and \x02 surrounding `$', which are invisible in a typical terminal), $ PS4='+\[$\]-' $ set -x $ echo hello +$- echo hello hello The impact of the latest commit is not just removing \x01 and \x02, but also interferes with how `promptvars' end up being applied. > Try it with --noediting; the same thing happens. The original issue is happening in an interactive session, where Readline is likely enabled. > The current devel behavior is consistent: if the prompt string is passed to > readline, the \[ and \] are converted to readline markers; if the prompt is > not passed to readline, they are ignored. I can agree that the current behavior is one possible consistent behavior, but could you take this as ``a feature request'' for another consistent behavior? That is, the removal of \x01 and \x02 is performed at the very last stage so that the behavior of the `promptvars' processing of PS0 and PS4 is unaffected. If you think it is not consistent with `the --noediting PS1', I think one can switch the behavior depending on `--noediting'. If line editing is disabled, \[\] may produce an empty string from the beginning. Otherwise, \[ and \] produce \x01 and \x02, which will later be properly processed or removed at the final stage. Actually, I think it is more consistent that `the --noediting PS1' behavior would be modified to match the proposed behavior of removing \x01 and \x02 at the very final stage. -- Koichi
