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

Re: Problem with arrays -- "unknown file attribute"



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