Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Bug / error in manpage.
- X-seq: zsh-users 17303
- From: Larry Schrof <larrys@xxxxxx>
- To: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- Subject: Bug / error in manpage.
- Date: Mon, 1 Oct 2012 18:08:36 +0000
- Accept-language: en-US
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=fb.com; h=from : to : subject : date : message-id : content-type : mime-version; s=facebook; bh=pUcve2gSm8cu+6WIPwvwPVRtsYJy92iGzaiTZccOICo=; b=j5/niB4g78Hnw503qC1CQRfViKahuH6OwfAyZbycTGnZ2DghfsLQwIQBC85DeGUNwB11 /c1oQF4f78RlFoXp4LYU2lfFhGNKmLm/wbfEy7aSaYStYdGdrQW1L4XcRbVmvwMwwAYS /+YK4OoTkMMg4/ha6Xz47XwJ2kZqQ1WO/tk=
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Thread-index: AQHNn//GKajF7pQVzUGqlU64C195lA==
- Thread-topic: Bug / error in manpage.
I have found an error in the manpage, or incomplete functionality -
whatever you'd like to call it.
If you are new to zsh and want to learn a couple of things, read
on. If you are a veteran and just want to read about the bug,
jump to the string '===' below in this email.
Context
Let's say I have a string that contains words separated by some
arbitrary token. I'll pick a line from /etc/passwd:
zsh% string=$(grep '^nobody' /etc/passwd)
$() is the same as backticks, but better.
zsh% print $string
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false
Let's say we want to get the value of the second field.
Let's try something naive:
zsh% print $string[2]
o
zsh%
That doesn't work - by default it indexes on characters if
it's a scalar. Let's use the split-on-word flag:
zsh% print $string[(w)2]
User:/var/empty:/usr/bin/false
Nope - that's not what we want. It split on whitespace.
We want to tell it to split on colons:
zsh% print $string[(ws{:})2]
*
zsh%
Excellent that's what we want!
===
The man page for subscripting flags is incorrect. Here is the excerpt:
The flags s, n and b take an argument; the delimiter is shown below as
`:', but any character, or the matching pairs `(...)', `{...}',
`[...]', or `<...>', may be used.
The '< >' brackets do not work as separators:
zsh% print $string[(ws<:>)2]
zsh: parse error near `)'
zsh%
This is exactly like the previous command, except the curly braces were changed
to arrow brackets.
Can we either update the manpage, removuing mention of '<...>', or add the ability
to parse them?
Thanks!
===
Messages sorted by:
Reverse Date,
Date,
Thread,
Author