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

Re: nesting issue





On 2024-05-04 20:20, Bart Schaefer wrote:
They give "bad substitution" because you can't have a space before the
closing "}" / after the closing ")" in the parameter expansion.

local sorted=( "${(f)$(print -l "${(n)in[@]}")}" )

Nuts, I wouldn't have even considered that.  

Even tho it is accepted here?:

    sorted=( "${(f)sorted}" )

I've tended to space things out for legibility, ok, good to know that sometimes the parser doesn't like it.  It really is nit picking but 'that' space seems to be 'outboard' of the actual text substitution, IOW it seems as if the swapping of 'sorted' for '$(print -l "${(n)in[@]}")'
is accepted verbatim an *then* the issue with the space comes up after the fact.  Not that it's worth worrying about.  I consider the parser to be a miracle worker as it is. 

One thing tho, since nested quotes end up un-quoting the inner quotation (or is this an exception?), I'm thinking that:

 local sorted=( "${(f)$(print -l ${(n)in[@]})}" )

... one set of quotes -- should be fine.  And it seems fine.  Or is this one of those things where spaces in filenames is going to gotcha me?





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