How to escape?

Jun 8, 2013
98
0
Warsaw, Poland
Hello. A small trouble.

I want to show something in color.
Like that
Code:
*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 ( ) -> [ ]
Code:
*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?
 
May 20, 2008
12,171
133
Syracuse, NY, USA
Just escape the '[' characters in the ANSI sequences.
Code:
v:\> set title=foo

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