Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: zsh -n does not detect incorrect associative array declaration
- X-seq: zsh-workers 38213
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: zsh -n does not detect incorrect associative array declaration
- Date: Wed, 23 Mar 2016 19:08:30 -0700
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=9Uxb4M9829JARtmEhWuVr36L2WQ4uPIZECCDPVZ2ogo=; b=Dgmn336FZiJQb7WCvviyd7xJ5xHHsRc5jPhd7ruxyy+KYewtXelmlVZ9CrKiW/wlI3 Yl9U9G7kgMwdkfoTANFFC0z0QdAOfG7Ye/Fqa3Uo5goMRdvlKsRnYGR59DGyUp66am/6 GnXONxggYUQ3CL+ICLM3iRjTx2wwfy5CFUbw6GFIOsdVtNynbeVOlTwpOaRtxZNKculu 0dnu13bSUMQpPxk4ZxanQTNHHKNQi1PL3CbDgPg5vcHyODKb9wLtWmuGElKCgpxQlk7a oirn2c1YwbbDEDrqUEpjOIZhe/OT5juohHXvAXzD9IyXmnWnbr07t5LOFHjPf/XqxyOv ky3w==
- In-reply-to: <20160323092338.492731f9@pwslap01u.europe.root.pri>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <56F1C3D7.6020800@redhat.com> <CAH+w=7YDbbw_J2G6BJKqi9=MtymqAQo1Zhv-19FGK0RqFnyScA@mail.gmail.com> <56F1FF5F.6060907@redhat.com> <CAH+w=7bkphoEdbFzXbU4_UXNWjr8M1UMUuO0QAiOfh=QR--1Ww@mail.gmail.com> <20160323092338.492731f9@pwslap01u.europe.root.pri>
On Mar 23, 9:23am, Peter Stephenson wrote:
} Subject: Re: zsh -n does not detect incorrect associative array declaratio
}
} On Tue, 22 Mar 2016 23:40:54 -0700
} Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
} > Contrast this with ksh where associative array assignments look like
} >
} > fn=( [foo_key]=foo_val [bar_key]= )
} >
} > forcibly changes the type of "fn" to become an associative array
}
} Off the original topic, but actually it doesn't, at least not in bash.
I'd forgotten that bash even supports that syntax, but in any case it
does change the type in ksh.
$ typeset -a x
$ typeset -p x
typeset -a x
$ x=( [a]=1 [b]=2 )
$ typeset -p x
typeset -A x=([a]=1 [b]=2)
$
Bash allows you to set numerically-indexed positions in a normal array
with the ( [key]=value ) syntax, and also outputs the arrays that way
with "typeset -p". You can have sparse arrays in bash.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author