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

[PATCH] Documentation incorrect re: (w) subscript flag



The documentation for the (w) subscript flag states:

> If the parameter subscripted is a scalar then this flag makes subscripting
> work on words instead of characters. The default word separator is whitespace.
> This flag may not be used with the i or I flag.

The last bit is not accurate — it does have an effect (one of the two that i
would consider 'expected') when used with (i) and (I):

% str='a bbb bb bb'; print ${str[(i)bb]}
3
% str='a bbb bb bb'; print ${str[(iw)bb]}
7
% str='a bbb bb bb'; print ${str[(Iw)bb]}
10

Daniel wasn't sure how to correctly document this behaviour. Might i suggest the
following?

dana


diff --git a/Doc/Zsh/params.yo b/Doc/Zsh/params.yo
index 5757111b2..b569a9358 100644
--- a/Doc/Zsh/params.yo
+++ b/Doc/Zsh/params.yo
@@ -328,8 +328,10 @@ startitem()
 item(tt(w))(
 If the parameter subscripted is a scalar then this flag makes
 subscripting work on words instead of characters.  The default word
-separator is whitespace.  This flag may not be used with the tt(i) or
-tt(I) flag.
+separator is whitespace.  When combined with the tt(i) or tt(I) flag,
+the effect is to produce the index of the first character of the
+first/last word which matches the given pattern; note that a failed
+match in this case always yields 0.
 )
 item(tt(s:)var(string)tt(:))(
 This gives the var(string) that separates words (for use with the




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