On Mon, Mar 21, 2022 at 4:01 AM Michaelll Lee <lwl2...@gmail.com> wrote:

> . . .
> While using non-printing characters without "\[...\]" proves to be fine in
> versions prior to 5.x.x (e.g., many suggestions from some online forums
> have suggested "PS1=\e[0m" for using ANSI escape code in the prompt), the
> same configuration in 5.x.x is not as stable as the previous versions(i.e.,
> "PS1=\[\e[0m\]" should be used instead of "PS1=\e[0m", otherwise the
> unexpected behavior(STEP7) will happen).
> . . .


Note that the difference you see in Bash 5 is due to new paste behavior.
However, prior versions are *not* fine without the escaped brackets. Bash
loses track of the position of the cursor if there are unbracketed
non-printing sequences. This is visible when stepping back through commands
in history and a long command wraps, for an example.
https://mywiki.wooledge.org/BashFAQ/053

Reply via email to