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

Corection RE: Final touch? RE: PATCH: more substitution documentation



>
> So, the whole for a ${(flags)var-mods} looks like
>
>  1. take the value of var. The result is list (array) of words
> (may be empty or having only one element)
>  2. If this is quoted and no (@) is present, join the list with
> the first character if IFS (I think, it is correct? Not always
> with space?) thus producing a single word (again, actually a list
> with single word)
>  3. apply mods separately for every word in list
>  4. join the words again if (j) is present
>  5. split using (s) or $= if present
>  6. If no $= or (s) is present and the whole is not quoted, apply
> SH_WORD_SPLIT:
>  7. the result is again a (possibly empty) list of words. If the
> whole is not quoted, the empty words are removed
>

Correction for 2 and 4:

 2. If this is quoted and no (@) or (j) is present, join words with first
character of IFS (tested); else if quoted and (j), but not (@), is present,
join with given string. It seems, that only the last (j) (and probably (s))
is used
 4. - if quoted and both (j) and (@) are present or not quoted, join with
given string

itsrm2% IFS=:
itsrm2% foo=(a b)
itsrm2% args $foo
2
a
b
itsrm2% args "$foo"
1
a:b
itsrm2% args "${(j/x/)foo}"
1
axb
itsrm2% args "${(j/x/j/y/)foo}"
1
ayb

 4. - if quoted and both (j) and (@) are present or not quoted, join with
given string

itsrm2% foo=(a1 b1)
itsrm2% args "${(@j/x/)foo%1*}"
1
axb
itsrm2% args "${(j/x/)foo%1*}"
1
a1xb
itsrm2% args ${(j/x/)foo%1*}
1
axb

I would not call it very consistent (but, well, it mostly the same as used
with splitting), but as long as you know the rules ... :-)

cheers

/andrej



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