From: Jim <linux.tech.guy@gmail.com>
To: zsh-workers@zsh.org
Subject: The Z Shell Manual, zsh/mapfile documentation correction
Date: Sun, 1 Sep 2013 17:34:38 -0500 [thread overview]
Message-ID: <CA+rB6G+6vcuH7O_-SgZw3nX168shKdTCm3_AKFTKPqpFwt5U_A@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1357 bytes --]
Hello,
While working on a zsh script, I researched using module zsh/mapfile to
read a file into an array for further processing. Trying the example from *The
Z Shell Manual*(Section 22.15) I found that it didn't work as stated. It
failed to read in blank lines. I had also noticed an extra element in the
array.
Example: array=("${(f)mapfile[*filename*]}")
also
egrep -v '^$' filename | wc -l yielded n lines
print ${#array} yielded n+1 elements
Not that I needed the blank lines, in this case, but it did not read them
into the array. After some web searching I found that this was discussed
on zsh-users in the 2008 thread *reading a file into an array. mapfile? (f)?
*. URL: http://www.zsh.org/mla/users/2008/msg00849.html. The fix was
actually stated in URL: http://www.zsh.org/mla/users/2008/msg00874.html.
Correction: array=("${(f@)mapfile[*filename*]}")
The discussion also stated the fact that an extra element(blank) is added
to the end of the array. It would be nice to have a statement in *The Z
Shell Manual* that the array will contain an additional element. I'm not
sure I agree that this should be the result, but I'll leave that to others
more knowledgeable about the subject.
Versions of the manual I checked are:
4.3.17 -- This is also the version of zsh I'm using(OS: Debian Wheezy).
5.0.2-dev-0
Sincerely,
Jim
next reply other threads:[~2013-09-01 22:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-01 22:34 Jim [this message]
2013-09-02 9:20 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+rB6G+6vcuH7O_-SgZw3nX168shKdTCm3_AKFTKPqpFwt5U_A@mail.gmail.com \
--to=linux.tech.guy@gmail.com \
--cc=linuxtechguy@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).