Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Problem with arrays -- "unknown file attribute"
- X-seq: zsh-users 13649
- From: "Benjamin R. Haskell" <zsh@xxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxxxxx>
- Subject: Re: Problem with arrays -- "unknown file attribute"
- Date: Mon, 5 Jan 2009 14:03:33 -0500 (EST)
- In-reply-to: <b11ea23c0901051042w393b8aeey6e03082d63a39481@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <b11ea23c0901050004h4f1825egc01d39c1f74c0ef0@xxxxxxxxxxxxxx> <alpine.LNX.2.00.0901050308270.17470@xxxxxxxxxxxxxxx> <20090105092403.GA7733@xxxxxxxxxxxxxxx> <alpine.LNX.2.00.0901050426390.17470@xxxxxxxxxxxxxxx> <m3fxjxenta.fsf@xxxxxxxxxxxxxx> <b11ea23c0901050931q790f8804tdbc8807c0c51a086@xxxxxxxxxxxxxx> <20090105181731.GA4857@xxxxxxxxxxxxxxx> <b11ea23c0901051042w393b8aeey6e03082d63a39481@xxxxxxxxxxxxxx>
On Mon, 5 Jan 2009, Webb Sprague wrote:
Thanks Stephane for all your comments on zsh scripting. I just have
one question below...
Or you could keep the default value of IFS which in zsh is $' \t\n\0'
(in other shells it's $' \t\n' as they don't support the NUL character
anyway).
What does the dollar do in IFS? I actually have to get rid of it in
order to make the script work. I think it might be part of the reason
all of my array conversions have been giving me hell, actually.
The dollar is part of a Zsh quoting mechanism. From man zshall:
A string enclosed between â$'â and â'â is processed the same way as the
string arguments of the print builtin, and the resulting string is
considered to be entirely quoted. A literal â'â character can be included
in the string by using the â\'â escape.
I'd be surprised if:
IFS=' \t\n'
did what you want it to. E.g.
## set up a test variable
$ R=$(print "sep arated\nnewline\nby\ta\ttab")
$ print -R $R
sep arated
newline
by a tab
## with IFS and no dollar-quoting -- note that it splits on 't's and 'n's
$ IFS=' \t\n'
$ TABS=( ${=R} ) ; print -l $TABS
sep
ara
ed
ewli
e
by a
ab
## with dollar-quoting
$ IFS=$' \t\n'
$ TABS=( ${=R} ) ; print -l $TABS
sep
arated
newline
by
a
tab
Messages sorted by:
Reverse Date,
Date,
Thread,
Author