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

Re: (j.|.)



On Tue, Jan 31, 2023 at 8:14 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> On 2023-01-31 10:10, Roman Perepelitsa wrote:
>
> print -r -- ${(j.|.)@}
>
> Ah!  I tried printing everything but that -- the obvious thing.  Ok, so the multiple args are converted to one string with bars between and somehow that ends up as an array of space-separated args in '@'.  I think I'm missing something important, I can't recall any such thing with bars like that.  zsh knows that the pattern expands to parameters too, I'm ... I guess the pattern isn't expanded until we know were within the $parameters ... yeah, so that's fine.  But I'd better get this 'bars' thing straight.

Do you understand what this does?

    print -r -- ${(ok)parameters[(I)pa*|PA*]}

How about this?

    () { print -r -- ${(ok)parameters[(I)${(j.|.)@}]} } 'pa*' 'PA*'

Roman.




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