From: Jim <linux.tech.guy@gmail.com>
To: zsh-users@zsh.org
Subject: Re: Apparent inconsistency in f/z expansion flags behavior
Date: Sun, 18 Dec 2016 17:29:31 -0600 [thread overview]
Message-ID: <CA+rB6GL-zKg-u3YijYaBgWf59-WcRf-tDN2uqtF3YV8OuwM=Cw@mail.gmail.com> (raw)
In-Reply-To: <CAAiKvi0Ge4-9016srG4K5-3-VnwCXN5FcKtsjGtE6GjG8ZwGsA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1000 bytes --]
On Sun, Dec 18, 2016 at 5:02 PM, Pablo Lalloni <plalloni@gmail.com> wrote:
> Hello there!
>
> I'm seeing an unexpected (to me) difference in the behavior of these flags.
>
> Say you do something like:
>
> words=(${(z)$(</proc/meminfo)})
>
> Which set words with the array of all the words in the file and that's
> great.
>
> Then I try the f flag in place of z, expecting to get an array with the
> file's lines:
>
> lines=(${(f)$(</proc/meminfo)})
>
> But then I get an array with just one string containing all the lines
> concatenated (no NLs).
>
> So... Is this expected? What I need to do to get the array of lines?
>
> Note that if you split the last assignment in 2 steps, it works as
> expected:
>
> lines=$(</proc/meminfo)
> lines=(${(f)lines})
>
> Which is ok, but of course anybody would want to do it in one step, right?
>
> Cheers!
>
lines=("${(f)$(</proc/meminfo)}")
Should do what you want. You need the quotes. It took me a
while to get that into my own head.
Hope it helps,
Jim
next prev parent reply other threads:[~2016-12-18 23:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-18 23:02 Pablo Lalloni
2016-12-18 23:29 ` Jim [this message]
2016-12-19 2:08 ` Bart Schaefer
2016-12-19 15:02 ` Pablo Lalloni
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+rB6GL-zKg-u3YijYaBgWf59-WcRf-tDN2uqtF3YV8OuwM=Cw@mail.gmail.com' \
--to=linux.tech.guy@gmail.com \
--cc=linuxtechguy@gmail.com \
--cc=zsh-users@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).