zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] explicitly mention ${name:/pat/repl}
@ 2016-11-08 18:10 Bart Schaefer
  2016-11-09  5:14 ` Daniel Shahaf
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2016-11-08 18:10 UTC (permalink / raw)
  To: zsh-workers

I was annoyed how hard it was to search the docs for this.

Any inaccuracies?  Objections?

diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index f465b2f..f67796f 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -782,12 +782,14 @@ prepending tt($0).  Hence tt(${*:0:1}) substitutes tt($0) and
 tt(${*:1:1}) substitutes tt($1).
 )
 xitem(tt(${)var(name)tt(/)var(pattern)tt(/)var(repl)tt(}))
-item(tt(${)var(name)tt(//)var(pattern)tt(/)var(repl)tt(}))(
+xitem(tt(${)var(name)tt(//)var(pattern)tt(/)var(repl)tt(}))
+item(tt(${)var(name)tt(:/)var(pattern)tt(/)var(repl)tt(}))(
 Replace the longest possible match of var(pattern) in the expansion of
 parameter var(name) by string var(repl).  The first form
-replaces just the first occurrence, the second form all occurrences.
+replaces just the first occurrence, the second form all occurrences,
+and the third form replaces only if var(pattern) matches the entire string.
 Both var(pattern) and var(repl) are subject to double-quoted substitution,
-so that expressions like tt(${name/$opat/$npat}) will work, but note the
+so that expressions like tt(${name/$opat/$npat}) will work, but obey the
 usual rule that pattern characters in tt($opat) are not treated specially
 unless either the option tt(GLOB_SUBST) is set, or tt($opat) is instead
 substituted as tt(${~opat}).
@@ -803,8 +805,8 @@ single backslash; this is not necessary if the
 `tt(%)' and `tt(#%) are not active if they occur inside a substituted
 parameter, even at the start.
 
-The first `tt(/)' may be preceded by a `tt(:)', in which case the match
-will only succeed if it matches the entire word.  Note also the
+If tt(${)var(name)tt(}) expands to an array value, the replacements act
+on each element individually.  Quoting may affect this.  Note also the
 effect of the tt(I) and tt(S) parameter expansion flags below; however,
 the flags tt(M), tt(R), tt(B), tt(E) and tt(N) are not useful.
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] explicitly mention ${name:/pat/repl}
  2016-11-08 18:10 [PATCH] explicitly mention ${name:/pat/repl} Bart Schaefer
@ 2016-11-09  5:14 ` Daniel Shahaf
  2016-11-09  6:39   ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Shahaf @ 2016-11-09  5:14 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote on Tue, Nov 08, 2016 at 10:10:43 -0800:
> -The first `tt(/)' may be preceded by a `tt(:)', in which case the match
> -will only succeed if it matches the entire word.  Note also the
> +If tt(${)var(name)tt(}) expands to an array value, the replacements act
> +on each element individually.  Quoting may affect this.  Note also the

"Quoting may affect this"?  This leaves me wondering what the effect is
and under what circumstances it happens.

I assume this has to do with the «"${(@)foo}"» syntax?

>  effect of the tt(I) and tt(S) parameter expansion flags below; however,
>  the flags tt(M), tt(R), tt(B), tt(E) and tt(N) are not useful.
>  
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] explicitly mention ${name:/pat/repl}
  2016-11-09  5:14 ` Daniel Shahaf
@ 2016-11-09  6:39   ` Bart Schaefer
  2016-11-09  7:22     ` Bart Schaefer
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2016-11-09  6:39 UTC (permalink / raw)
  To: zsh-workers

On Nov 9,  5:14am, Daniel Shahaf wrote:
} Subject: Re: [PATCH] explicitly mention ${name:/pat/repl}
}
} Bart Schaefer wrote on Tue, Nov 08, 2016 at 10:10:43 -0800:
} > -The first `tt(/)' may be preceded by a `tt(:)', in which case the match
} > -will only succeed if it matches the entire word.  Note also the
} > +If tt(${)var(name)tt(}) expands to an array value, the replacements act
} > +on each element individually.  Quoting may affect this.  Note also the
} 
} "Quoting may affect this"?  This leaves me wondering what the effect is
} and under what circumstances it happens.

It just means that if you quote the expansion, it won't necessarily
be an array any more.  There are too many ways this could happen to
enumerate them all every time it might apply.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] explicitly mention ${name:/pat/repl}
  2016-11-09  6:39   ` Bart Schaefer
@ 2016-11-09  7:22     ` Bart Schaefer
  2016-11-09 17:10       ` Daniel Shahaf
  0 siblings, 1 reply; 5+ messages in thread
From: Bart Schaefer @ 2016-11-09  7:22 UTC (permalink / raw)
  To: zsh-workers

On Nov 8, 10:39pm, Bart Schaefer wrote:
}
} It just means that if you quote the expansion, it won't necessarily
} be an array any more.  There are too many ways this could happen to
} enumerate them all every time it might apply.

How about this, then.

diff --git a/Doc/Zsh/expn.yo b/Doc/Zsh/expn.yo
index f465b2f..87ca790 100644
--- a/Doc/Zsh/expn.yo
+++ b/Doc/Zsh/expn.yo
@@ -782,12 +782,14 @@ prepending tt($0).  Hence tt(${*:0:1}) substitutes tt($0) and
 tt(${*:1:1}) substitutes tt($1).
 )
 xitem(tt(${)var(name)tt(/)var(pattern)tt(/)var(repl)tt(}))
-item(tt(${)var(name)tt(//)var(pattern)tt(/)var(repl)tt(}))(
+xitem(tt(${)var(name)tt(//)var(pattern)tt(/)var(repl)tt(}))
+item(tt(${)var(name)tt(:/)var(pattern)tt(/)var(repl)tt(}))(
 Replace the longest possible match of var(pattern) in the expansion of
 parameter var(name) by string var(repl).  The first form
-replaces just the first occurrence, the second form all occurrences.
+replaces just the first occurrence, the second form all occurrences,
+and the third form replaces only if var(pattern) matches the entire string.
 Both var(pattern) and var(repl) are subject to double-quoted substitution,
-so that expressions like tt(${name/$opat/$npat}) will work, but note the
+so that expressions like tt(${name/$opat/$npat}) will work, but obey the
 usual rule that pattern characters in tt($opat) are not treated specially
 unless either the option tt(GLOB_SUBST) is set, or tt($opat) is instead
 substituted as tt(${~opat}).
@@ -803,8 +805,8 @@ single backslash; this is not necessary if the
 `tt(%)' and `tt(#%) are not active if they occur inside a substituted
 parameter, even at the start.
 
-The first `tt(/)' may be preceded by a `tt(:)', in which case the match
-will only succeed if it matches the entire word.  Note also the
+If, after quoting rules apply, tt(${)var(name)tt(}) expands to an array,
+the replacements act on each element individually.  Note also the
 effect of the tt(I) and tt(S) parameter expansion flags below; however,
 the flags tt(M), tt(R), tt(B), tt(E) and tt(N) are not useful.
 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] explicitly mention ${name:/pat/repl}
  2016-11-09  7:22     ` Bart Schaefer
@ 2016-11-09 17:10       ` Daniel Shahaf
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Shahaf @ 2016-11-09 17:10 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer wrote on Tue, Nov 08, 2016 at 23:22:52 -0800:
> +If, after quoting rules apply, tt(${)var(name)tt(}) expands to an array,
> +the replacements act on each element individually.  Note also the

+1, looks good to me.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-09 17:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-08 18:10 [PATCH] explicitly mention ${name:/pat/repl} Bart Schaefer
2016-11-09  5:14 ` Daniel Shahaf
2016-11-09  6:39   ` Bart Schaefer
2016-11-09  7:22     ` Bart Schaefer
2016-11-09 17:10       ` Daniel Shahaf

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