Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: print color escapes

On 01/01/2015 01:29 PM, Bart Schaefer wrote:

Excellent, the whole question boils down to this:

}      local lc=$'\e['

In that expression, the $'' form of quoting converts \e to ESC, which is
why the $'' form of quoting exists in the first place (and is different
from ordinary single quoting).  $'' is to avoid having to do something
more expensive (fork + read output) such as lc="$(echo '\e[')".

That is a POSIX quote? Good to see one in combat, I've only ever had them drawn to my attention once before. Book lernin' no substitute for seeing something in action.
The (V) flag converts ESC to ^[ because that's what most people are used
to seeing ("visible").  The (q) flag converts to $'\e' because that's
what people are used to writing (and because "eval ${(q)...}" needs it
in that format).

Beautiful, these are conventions and practicalities not 'realities'.
The print and echo commands convert \e to ESC because
of historical practice.
But terminal will always grab ESC 'hard' will it not? That is to say that no matter how you dress it up, the terminal always sees it verbatim. And I'd expect that that convention is now written in stone.
The bindkey command converts both ^[ and \e to
ESC for maximum flexibility in writing key bindings.  All of this is
entirely independent of what the terminal does when it sees an ESC.

Crystal clear. Too bad there wasn't some way of upvoting an explanation like that were it to show up on Google eventually, cuz that's as good as it could be. Questions that were not even asked (but needed to be) were answered.

BTW too bad in some fonts '' looks almost exactly like ".

Messages sorted by: Reverse Date, Date, Thread, Author