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

Re: coloring substitution seems to eat next line.

On 2022-11-10 10:54, Bart Schaefer wrote:

   cc[42]="foo bar"
   cc[42]=(foo bar)
The first one resets cc[42].  The second one both updates cc[42] and
inserts a new cc[43] after it.

Now there's a surprise.  Nuts, that explains the weird output and the seemingly empty next element.  It bleeding creates a new empty next element!!  I'll leave it to more adept people to understand why that's ever wanted.

Anyway, I stopped slicing (or did I start slicing? ...) anyway:

cc[$aa]=( ${cc[$aa]/(#b)((#i)$filter)/$'\e['$color;1m${match[1]}$'\e[0m'} )

... is the now slightly understandable strange output and ...


...  works just fine :-)  I've gotten into the habit of always using the parentheses just because.

There is also the form

cc[42,44]=(foo bar)

which removes three elements (42,43,44) and replaces them with two new
ones (42 and 43).  Hence a "slice".

Sheesh.  So it looks like I stopped slicing.  But that just above is sorta understandable.

BTW I'm not using Roman's '(#M)' syntax because it seems to want to print all sorts of values to the terminal.  Like '$MATCH' is some internal variable that always prints itself or something.

One last issue, tinkering with the code even as I compose this:


... the one thing left is to insert '$zsh_case' in there, which so far is not working.  But Roman has the answer:


... I have not idea what '$~' means, but it works.

BTW, to my surprise, using native code gives the same performance as using grep, 40 seconds on a stress test here.  sed wanted 43 seconds.

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