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

Re: coloring substitution seems to eat next line.



On Thu, Nov 10, 2022 at 11:28 AM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> I'll leave it to more adept people to understand why that's
> ever wanted.

It's just a quick way to lengthen or shorten arrays when not merely
adding elements at the end.

> 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

That would only be "strange" if the result in the parens somehow came
out as either nothing, or as two or more strings with a space between,
but ordinarily the fact that you're doing a single ${cc[$aa]}
(regardless of the replacements) would mean you get exactly one
element.

> I've gotten into the habit of always using the
> parentheses just because.

Most of the time you want the parens when assigning all the elements
of an array at once.  You should not use the parens for anything
that's meant to be a single string (or number).

> BTW I'm not using Roman's '(#M)' syntax because it seems to want to
> print all sorts of values to the terminal.

That's almost certainly because of
> > local MATCH MBEGIN MEND

which should never appear except inside a function, and should only
appear at the beginning of the function and not inside a loop.

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

$~foo (or ${~foo} means that the value of $foo should be interpreted
as a glob pattern rather than as a literal string.




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