How to escape?

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Hello. A small trouble.

I want to show something in color.
Like that
*Set title=something
*Echo --( %@If[%_ansi==1,^e[1;33m,]%[title]%@If[%_ansi==1,^e[0m,] )--
It works fine, doesn't matter if ANSI is enabled or not.

Now let's replace brackets ( ) -> [ ]
*Set title=something
*Echo --[ %@If[%_ansi==1,^e[1;33m,]%[title]%@If[%_ansi==1,^e[0m,] ]--
Last, closing brace ']' is interpreted as closing bracket of %@If[ ]
Of course, I can use extra variables, containing values of %@If[]'s.

How should it be written in one working line?
Just escape the '[' characters in the ANSI sequences.
v:\> set title=foo

v:\> Echo --[ %@If[%_ansi==1,^e^[1;32m,]%[title]%@If[%_ansi==1,^e^[0m,] ]--
--[ foo ]--