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

Re: (j.|.)



On Tue, Jan 31, 2023 at 5:39 PM Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
>
> Bart:
>
> Your clipped comments and code:
>
> # ${(j.|.)var} means to join an array with vertical bars; here the var
> is @ for the positional parameters.
>
> # ${~something} means the value of something can be treated as a
> pattern, so the |-joined positional parameters form a pattern.
>
> # "set --" replaces the original positional parameters with this array
> of parameter names.
>
> set -- ${(ok)parameters[(I)${_v_case}${~${(j.|.)@}}]}
>
> ... I understand everything but the '(j.|.)' -- it seems ok like this:
>
>      set -- ${(ok)parameters[(I)${_v_case}${~${@}}]}
>
> ... I see no vertical bars either before or after.  The PP's print as a
> spaced array either way.  But  you didn't but that in for no reason.
> Besides, the idea of joining the array seems backwards.

Try it with more than one argument to see the difference.

Roman.




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