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?



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