bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug Report] The Unexpected Behavior When Using ANSI Escape Code


From: Dennis Williamson
Subject: Re: [Bug Report] The Unexpected Behavior When Using ANSI Escape Code
Date: Mon, 21 Mar 2022 08:39:26 -0500

On Mon, Mar 21, 2022 at 4:01 AM Michaelll Lee <lwl20th@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

[Prev in Thread] Current Thread [Next in Thread]