zsh-workers
 help / color / mirror / code / Atom feed
* Corection RE: Final touch? RE: PATCH: more substitution documentation
@ 1999-03-18 15:57 Andrej Borsenkow
  0 siblings, 0 replies; only message in thread
From: Andrej Borsenkow @ 1999-03-18 15:57 UTC (permalink / raw)
  To: Andrej Borsenkow, Peter Stephenson, Zsh hackers list

>
> 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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1999-03-18 16:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-03-18 15:57 Corection RE: Final touch? RE: PATCH: more substitution documentation Andrej Borsenkow

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).