* creating associative arrays
@ 2001-12-11 18:45 Akos Szalkai
2001-12-12 10:28 ` Peter Stephenson
2001-12-12 12:30 ` Akos Szalkai
0 siblings, 2 replies; 5+ messages in thread
From: Akos Szalkai @ 2001-12-11 18:45 UTC (permalink / raw)
To: zsh-users
Hello,
I am trying to fill an associative array from a file. If the name of
the file is fixed, e.g. array.txt then the following works:
: ${(AA)dict::=$(<array.txt)}
However, if the filename is given in a parameter then the command:
: ${(AA)dict::=$(<${filename})}
gives the error
zsh: bad set of key/value pairs for associative array.
I guess I am mixing up some kind of expansion order, so could somebody
help?
Thanks in advance,
Akos
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: creating associative arrays
2001-12-11 18:45 creating associative arrays Akos Szalkai
@ 2001-12-12 10:28 ` Peter Stephenson
2001-12-12 12:13 ` Akos Szalkai
2001-12-12 12:30 ` Akos Szalkai
1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2001-12-12 10:28 UTC (permalink / raw)
To: Zsh users list
"Akos Szalkai" wrote:
> I am trying to fill an associative array from a file. If the name of
> the file is fixed, e.g. array.txt then the following works:
>
> : ${(AA)dict::=$(<array.txt)}
>
> However, if the filename is given in a parameter then the command:
> : ${(AA)dict::=$(<${filename})}
> gives the error
> zsh: bad set of key/value pairs for associative array.
There's not much that can go wrong there, if filename is set to array.txt
and that contains an even number of words. Are you sure it is and does?
Sorry, I don't think this is very helpful...
--
Peter Stephenson <pws@csr.com> Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK Tel: +44 (0)1223 392070
**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential
and/or privileged material.
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is
prohibited.
If you received this in error, please contact the sender and
delete the material from any computer.
**********************************************************************
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: creating associative arrays
2001-12-12 10:28 ` Peter Stephenson
@ 2001-12-12 12:13 ` Akos Szalkai
0 siblings, 0 replies; 5+ messages in thread
From: Akos Szalkai @ 2001-12-12 12:13 UTC (permalink / raw)
To: zsh-users
> There's not much that can go wrong there, if filename is set to array.txt
> and that contains an even number of words. Are you sure it is and does?
Yes to both. I am using zsh 4.0.4, and I can reproduce this by simply
putting key<TAB>value into array.txt. (The same happens on 3.1.6 and
with the stock 4.0.1pre3 on SuSE 7.2.)
The options set are the following (even though they do not seem to be
related):
autocd nobeep nobgnice completeinword correct cshnullglob extendedglob
histexpiredupsfirst histignoredups histignorespace histnostore
histverify nohup ignoreeof interactive login longlistjobs nonotify
Can anybody reproduce this?
Akos
--
Akos Szalkai <szalkai@2f.hu>
IT Consultant
2F 2000 Szamitastechnikai es Szolgaltato Kft.
Tel: (+36-1)-4887700 Fax: (+36-1)-4887709 WWW: http://www.2f.hu/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: creating associative arrays
2001-12-11 18:45 creating associative arrays Akos Szalkai
2001-12-12 10:28 ` Peter Stephenson
@ 2001-12-12 12:30 ` Akos Szalkai
2001-12-14 16:31 ` Bart Schaefer
1 sibling, 1 reply; 5+ messages in thread
From: Akos Szalkai @ 2001-12-12 12:30 UTC (permalink / raw)
To: zsh-users
On Tue, Dec 11, 2001 at 07:45:22PM +0100, Akos Szalkai wrote:
> I am trying to fill an associative array from a file. If the name of
> the file is fixed, e.g. array.txt then the following works:
>
> : ${(AA)dict::=$(<array.txt)}
>
> However, if the filename is given in a parameter then the command:
> : ${(AA)dict::=$(<${filename})}
> gives the error
> zsh: bad set of key/value pairs for associative array.
Sorry for having a conversation with myself here, but I realized that it
has to do with splitting. If in the second case I use
: ${(AA)=dict::=$(<${filename})}
or anything similar, like
: ${(AA)dict::=${(z)$(<${filename})}}
it all works. Thinking about it (hopefully with a clearer head than last
night) the error message seemed to be the correct behavior.
However, the question remains: why did the first case (with the filename
given directly instead of by a parameter) work then?
Akos
--
Akos Szalkai <szalkai@2f.hu>
IT Consultant
2F 2000 Szamitastechnikai es Szolgaltato Kft.
Tel: (+36-1)-4887700 Fax: (+36-1)-4887709 WWW: http://www.2f.hu/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: creating associative arrays
2001-12-12 12:30 ` Akos Szalkai
@ 2001-12-14 16:31 ` Bart Schaefer
0 siblings, 0 replies; 5+ messages in thread
From: Bart Schaefer @ 2001-12-14 16:31 UTC (permalink / raw)
To: Akos Szalkai, zsh-users
On Dec 11, 7:45pm, Akos Szalkai wrote:
}
} I am trying to fill an associative array from a file. If the name of
} the file is fixed, e.g. array.txt then the following works:
}
} : ${(AA)dict::=$(<array.txt)}
}
} However, if the filename is given in a parameter then the command:
} : ${(AA)dict::=$(<${filename})}
} gives the error
} zsh: bad set of key/value pairs for associative array.
This is a side-effect of the bug that was fixed in zsh-workers/16215.
That was about a week after the 4.0.4 release; the above works in the
latest 4.1.0-dev. I haven't committed that patch on the 4.0 branch yet.
[Unrelated admin note: My ISP is playing games with me again, so any
mail directed to schaefer@candle.brasslantern.com or to any other third-
or greater-level domain in brasslantern.com, will bounce. Mail sent to
schaefer@brasslantern.com will get through.]
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-12-14 16:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-11 18:45 creating associative arrays Akos Szalkai
2001-12-12 10:28 ` Peter Stephenson
2001-12-12 12:13 ` Akos Szalkai
2001-12-12 12:30 ` Akos Szalkai
2001-12-14 16:31 ` 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).