zsh-users
 help / color / mirror / code / Atom feed
* why isn't IFS=$'\n' doing what I expect it to do here?
@ 2013-03-24  2:01 TJ Luoma
  2013-03-24  3:09 ` Phil Pennock
  2013-03-24  3:47 ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: TJ Luoma @ 2013-03-24  2:01 UTC (permalink / raw)
  To: Zsh-Users List

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<


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-03-24  4:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-24  2:01 why isn't IFS=$'\n' doing what I expect it to do here? TJ Luoma
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

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).