[Top][All Lists]

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

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

From: Michaelll Lee
Subject: Re: [Bug Report] The Unexpected Behavior When Using ANSI Escape Code
Date: Mon, 21 Mar 2022 17:00:29 +0800

Have it solved by following that manual page and using "\[ ... \]"
combination. Thanks for the hint!

By the way,  apparently the content about "non-printing characters" in that
man page has not been modified across the several versions of Bash, for
example in my machine, "3.2.57(1)-release" and "5.1.0(1)-release" share
nearly the same document for section "PROMPTING", and both of them have not
mentioned about the necessity to wrap around the non-printing characters
with "\[...\]".

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).

This might not be a bug for the current release of Bash, but we, as
long-term users, indeed needs to add some extra configurations to Bash5
make things work as normal as the versions prior to 5.x. According to my
limited tests, "Using standard ANSI escape code in prompt variable PS1" is
exactly the case. I think it would be better to document it in man
page/manual, or at least give a hint/warning for using non-printing

Nevertheless, Bash Long Live!

On Sun, Mar 20, 2022 at 10:43 PM Andreas Schwab <schwab@linux-m68k.org>

> On Mär 20 2022, Michaelll Lee wrote:
> > 1) $ PS1='---Test \\ \e[0m ---\\$ '
> Read the manual about non-printing characters in the prompt.
> https://www.gnu.org/software/bash/manual/html_node/Controlling-the-Prompt.html
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."

reply via email to

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