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?
- X-seq: zsh-users 17730
- From: TJ Luoma <luomat@xxxxxxxxx>
- To: Zsh-Users List <zsh-users@xxxxxxx>
- Subject: why isn't IFS=$'\n' doing what I expect it to do here?
- Date: Sat, 23 Mar 2013 22:01:14 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:from:date:message-id:subject:to :content-type; bh=Vm5IxALrTXLmzOpY497AYHa2O66u9q0zc1dtRw13L7k=; b=iSdixNks86zKia64mdM+T4UF7GJ/sYJDd5WAR1iOzDU4yXEraLNoC911GabuFLiPrc HF3D/Pp59EJ6i0nSNLtkF9gkDdLp+YFD9nHFtKxFbiL7r3s0Dd1M7YDj8RAAWI/0RnuV PByRA+A+kDi6YCSIuX7fEX/RmJ2iytFwMExcSPG6+H5owKRovvK2UPPzzLL9LCI1iCOv DVqINvI5NuLXDBqX1F3aB4HozT1VmdhL0Qp4+yZItGDlnH0nKNUjKVTT/hnY2m4G0QYC lqyWMG2SjWVvMbDrtL6DM8MPTQlLEFQCnZHvGO9Wiz+t/MI3FAS+jJi8DV4SjQkW45gX SrSw==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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