Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Apparent inconsistency in f/z expansion flags behavior
- X-seq: zsh-users 22233
- From: Jim <linux.tech.guy@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Apparent inconsistency in f/z expansion flags behavior
- Date: Sun, 18 Dec 2016 17:29:31 -0600
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to; bh=fELkO+TkeR6JoG9gx60wkqaBuQrNMFor13gUzDqz1cE=; b=kCLkvAhLciN2fRALUk7k5Oo4x1j2j6NLNqgPOd3w+kAMx4VvEJSpY0iKL9FFN+pgKy aRC45ETjTkkU+1+YTuyI4VJTYjNG/fQIpydmk9Exep+TrO2bNhNpTlKiEF/y2VhjryWw vzords26eTiYcmLB29kCLGqUIVxoJSlVSmA4O+AYgNsCyOF4ce3V1MB81yq4kEnqFyXC cvBlGNC0e5mNoSeo1etUfGZARBNLaHhoGL1P7/PZ46siUJeGBN1zvCXFKBPPBY/ESGXN rNPK3QCE3Y64WG4S2QlQZsRcgi8qvxbtvKAsBi9VSmhZmwpOk9FMDpJTtc+kTVh2E3Ej RWbQ==
- In-reply-to: <CAAiKvi0Ge4-9016srG4K5-3-VnwCXN5FcKtsjGtE6GjG8ZwGsA@mail.gmail.com>
- 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
- References: <CAAiKvi0Ge4-9016srG4K5-3-VnwCXN5FcKtsjGtE6GjG8ZwGsA@mail.gmail.com>
- Reply-to: linuxtechguy@xxxxxxxxx
On Sun, Dec 18, 2016 at 5:02 PM, Pablo Lalloni <plalloni@xxxxxxxxx> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author