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

Re: Belaboring substitution syntax

On 2022-11-15 17:49, Bart Schaefer wrote:
BTW you need to stop thinking of these as "lines" -- line breaks have
nothing to do with it.
Because I've never had an element that was more than one line I tend to say 'lines' but I know abstractly what you're saying.  I'll crash into the issue eventually and I'll be ready for it.
Conversely if you write "${array}" or ${array[*]}" either one with the
quotes, you get the entire array joined into a single string.
Right, that's quotes doing joining which I expect.
Quotes ALWAYS protect SOMETHING from expansion or interpretation,
unless you start throwing other things in there such as eval.  WHAT is
protected differs:  Double quotes allow ${param} and $(process) and
$((math)) replacements but protect syntax tokens and glob patterns and
whitespace; single quotes protect pretty much everything.
Yeah, I get all that.  There are times when I want to protect but not join tho and it gets confusing.
In the specific example in this thread, zsh's default array behavior
(no_SH_WORD_SPLIT) is sufficient, but if you later enclose that or a
similar construct in a deeper context, yes, you might be bitten.
I'll stay safe.
Your trouble is the definition of "nothing."  ${B:#*A*} does that, but
in your example here, you don't actually want "nothing", you want "the
empty string" which is still something.
Quite so, rather sloppy of me to say 'nothing', I know better.
About the only thing your magical operator could remove is putting
*...* around the pattern to mean "is a substring".

Well no, I *define* my operator to do just as I said (except that I should have said 'empty string').  All that puzzles me is that it's not already available.  Mind, functionality is added as needed so it's sufficient to just say that nobody has much wanted such a thing -- which is not debatable.  It's a fact on the ground that my operator doesn't exist ergo it's not been in demand and that's that.   So long is my functionality is achievable the rest is just musing.  Still I'd have expected it to be one of the earlier operators because it's the simplest case.  Nevermind.

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