Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: why isn't IFS=$'\n' doing what I expect it to do here?
- X-seq: zsh-users 17731
- From: Phil Pennock <zsh-workers+phil.pennock@xxxxxxxxxxxx>
- To: TJ Luoma <luomat@xxxxxxxxx>
- Subject: Re: why isn't IFS=$'\n' doing what I expect it to do here?
- Date: Sat, 23 Mar 2013 23:09:38 -0400
- Cc: Zsh-Users List <zsh-users@xxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=spodhuis.org; s=d201210; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To:From:Date; bh=dT+qP7tz82289DzzesVM9cuSvTAOxSJzrk0ARPb/iD4=; b=vc1IxBKgUMonJh+DbQDvkSGK7iNjztTssPyaJtpBrI6+JAiZ5TtOBN8o5JVRqY52veVObj1xJx8jKBMyHCo/8vjMrsbg8NBiMSQoKOkoHtqhYseERunlRxKuR2/7HsSSbhO0p75fTG9tDfibRWY9fachLtw47LFVpUstd1D3BOc=;
- In-reply-to: <CADjGqHsO-Ysi5KWwLU_SwkGJubcMsM-rFmBvfHw7Fq5ZsuyErg@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>
- Mail-followup-to: TJ Luoma <luomat@xxxxxxxxx>, Zsh-Users List <zsh-users@xxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CADjGqHsO-Ysi5KWwLU_SwkGJubcMsM-rFmBvfHw7Fq5ZsuyErg@mail.gmail.com>
On 2013-03-23 at 22:01 -0400, TJ Luoma wrote:
> I don't understand why IFS=$'\n' doesn't seem to be doing what I'd expect here:
>
> $ cat test-arrays.zsh
> IFS=$'\n' APPS=(
This isn't command or parameter expansion, or reading data with the read
builtin.
IFS would apply if you put the data into a variable and then caused
parameter expansion with splitting on IFS, eg by using the = parameter
expansion modifier, or setting sh_word_split.
This is input parsing, for assignment to a variable, not parameter
expansion. Mind, that doesn't mean that thinking through this isn't
giving me a headache.
----------------------------8< cut here >8------------------------------
% APPS=(${(f)${:-'
Alfred 2
Bartender
ddnsa
Fantastical
Flycut
HazelHelper
MagiCal
MenuBarFilter
Mountain
Should I Sleep
SizeUp
Trickster
'
}} )
----------------------------8< cut here >8------------------------------
Is that closer?
Note though that leading (and trailing) whitespace becomes significant.
Similarly, you can use:
APPS=(${=${:-'
for the first line, to actually split on $IFS, in which case changing
IFS does affect parsing here.
-Phil
Messages sorted by:
Reverse Date,
Date,
Thread,
Author