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

Re: (j.|.)




On 2023-01-31 12:19, Roman Perepelitsa wrote:

Do you understand what this does?

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

I'm afraid I don't, never seen anything like it before this.  But I'd better find out.  I'm sure I've seen the pipe char. as an operator.  Alternation, no?  But never in this sort of context. That would make sense: this pattern OR that pattern.  Above, obviously lower or upper case 'pa'.   Except that I can throw three or more patterns at the command so that would require another vertical bar, no? : ... pattern1 | pattern2 | pattern3 ... so if it only accepted two patterns I'd say that's it for sure, but it takes more than two.

 ... but wait ... the 'j' ... I don't know where to read up on that ... is it perhaps saying: 'keep on joining forever'?  Again, I've never seen it before, but if that's correct, then that's the answer -- join everything.  So then the bar in the string is in fact an operator, as I suspected, yes?  Then '(I)' matches anything in the alternation string and feeds the correct index # into the machinery there which then grabs the appropriate name. Sorta.  Yeah, that's gotta be it.  The tree I was barking up, was that somehow the aa|bb|cc ... was being directly converted into aa bb cc.  No, the former is a huge alternation.  Yes?  'j' is the power in this.









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