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

Re: coloring substitution seems to eat next line.

On 2022-11-10 12:22, Bart Schaefer wrote:

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).
Slowly I figure out what's really going on and don't have to rely on rote copying of syntax.
which should never appear except inside a function, and should only
appear at the beginning of the function and not inside a loop.
Heavy duty diagnostic stuff it seems.
$~foo (or ${~foo} means that the value of $foo should be interpreted
as a glob pattern rather than as a literal string.

Ah!  When you type it in there verbatim it seems to always be the pattern, but as a variable who's to say that the intention is?  So some way of making it explicit avoids semantic confusion.  That's robust, I like it.  One more little thing:

if [[ "$string" ]]; then

... to delete non-matching lines, but I'll bet there's a better way than this failed substitution.

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