Re: [Help-bash] Why bash does not recoganize array type smartly?
From:
Greg Wooledge
Subject:
Re: [Help-bash] Why bash does not recoganize array type smartly?
Date:
Wed, 16 Mar 2016 08:24:22 -0400
User-agent:
Mutt/1.4.2.3i
On Wed, Mar 16, 2016 at 01:12:18AM +0000, Dan Douglas wrote:
> On Tue, Mar 15, 2016 at 8:54 PM, Stephane Chazelas
> > zsh's syntax to define an associative array as a whole is a lot
> > saner:
> >
> > typeset -A a
> > a=(
> > key1 value1
> > key2 value2
> > )
> > [...]
> > Note that since 5.1, zsh supports
> >
> > typeset -A a=(k1 v1 k2 v2)
>
> Oh I see. That's kind of nice but unintuitive.
It's 100% intuitive coming from Tcl, which uses almost exactly the same
syntax for (associative) array definitions.
$ tclsh /dev/stdin <<'EOF'
> array set a {k1 v1 k2 v2}
> puts $a(k2)
> EOF
v2
The list of key/value pairs can be split across lines however you want.
E.g.:
array set a {
k1 v1
k2 v2
}
If Stephane can introduce zsh and C#, then Tcl seems fair game.