Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Documentation incorrect re: (w) subscript flag
- X-seq: zsh-workers 41924
- From: dana <dana@xxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH] Documentation incorrect re: (w) subscript flag
- Date: Tue, 17 Oct 2017 12:41:48 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dana-is.20150623.gappssmtp.com; s=20150623; h=from:content-transfer-encoding:mime-version:subject:message-id:date :to; bh=UZgQUh/ocXuMFGtqjRNZcLAmmaoNPO8D2fJNf+WO4r0=; b=Qfb7iLFzBlra1WRbwpfoRsmulBWZDZxqZ46Str/e7F3NV+28taZhj2s7Qu9wCmwEny CI/lxQC1iElW5kSbYApIb5q1O60A8vC5+5Ixo/iXSNeL5PORxvfyoC8qeKCXe98Cv5XJ g62OfGtCJEnGQN2kTywxMJmmlIh065v3t+ZidGsu9hdsCt2J0gVVAvkWchxJBoS+1e71 ijrLnZjSPEX7P2ZS6G9P9KVZ+KrpmpJ0mcQPbsPf1XyY/6AGh79IWD82W2uUMWKcKi3T wDMKri750dQh30uu+yo/JyxZ+8UQ2rEMYcWB6bigQ+4R/M8xBxdcoDCDISuJSilZt/wz BCPA==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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