zsh-users
 help / color / mirror / code / Atom feed
From: TJ Luoma <luomat@gmail.com>
To: Zsh-Users List <zsh-users@zsh.org>
Subject: why isn't IFS=$'\n' doing what I expect it to do here?
Date: Sat, 23 Mar 2013 22:01:14 -0400	[thread overview]
Message-ID: <CADjGqHsO-Ysi5KWwLU_SwkGJubcMsM-rFmBvfHw7Fq5ZsuyErg@mail.gmail.com> (raw)

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=(
		Alfred 2

		Bartender

		ddnsa

		Fantastical
		Flycut

		HazelHelper

		MagiCal
		MenuBarFilter
		Mountain

		Should I Sleep
		SizeUp

		Trickster
)

echo "5 is: $APPS[5]"

for f in $APPS
do

	echo ">$f<"

done


(Result of the command is)

5 is: Fantastical
>Alfred<
>2<
>Bartender<
>ddnsa<
>Fantastical<
>Flycut<
>HazelHelper<
>MagiCal<
>MenuBarFilter<
>Mountain<
>Should<
>I<
>Sleep<
>SizeUp<
>Trickster<

I thought that IFS=$'\n' would make it so I didn't have to escape the
spaces in the lines which had them.

If I take OUT the IFS line and escape the spaces, it works as I'd expect


APPS=(
		Alfred\ 2

		Bartender

		ddnsa

		Fantastical
		Flycut

		HazelHelper

		MagiCal
		MenuBarFilter
		Mountain

		Should\ I\ Sleep
		SizeUp

		Trickster
)

echo "5 is: $APPS[5]"

for f in $APPS
do

	echo ">$f<"

done

(Result of the command is)

5 is: Flycut
>Alfred 2<
>Bartender<
>ddnsa<
>Fantastical<
>Flycut<
>HazelHelper<
>MagiCal<
>MenuBarFilter<
>Mountain<
>Should I Sleep<
>SizeUp<
>Trickster<


             reply	other threads:[~2013-03-24  2:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-24  2:01 TJ Luoma [this message]
2013-03-24  3:09 ` Phil Pennock
2013-03-24  3:27   ` TJ Luoma
2013-03-24  4:46     ` Phil Pennock
2013-03-24  3:47 ` Bart Schaefer

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=CADjGqHsO-Ysi5KWwLU_SwkGJubcMsM-rFmBvfHw7Fq5ZsuyErg@mail.gmail.com \
    --to=luomat@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).