Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

why isn't IFS=$'\n' doing what I expect it to do here?



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<



Messages sorted by: Reverse Date, Date, Thread, Author