From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1181 invoked by alias); 14 Jul 2017 01:48:03 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41427 Received: (qmail 6058 invoked from network); 14 Jul 2017 01:48:03 -0000 X-Qmail-Scanner-Diagnostics: from dmz-mailsec-scanner-1.mit.edu by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(18.9.25.12):SA:0(-2.3/5.0):. Processed in 0.45503 secs); 14 Jul 2017 01:48:03 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: andersk@mit.edu X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at mit.edu designates 18.9.25.12 as permitted sender) X-AuditID: 1209190c-875ff700000065ef-94-5968219d9d56 Date: Thu, 13 Jul 2017 21:42:50 -0400 (EDT) From: Anders Kaseorg To: Bart Schaefer cc: "zsh-workers@zsh.org" Subject: Re: Array expansion interacts with brace expansion in the wrong order In-Reply-To: Message-ID: References: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrLIsWRmVeSWpSXmKPExsUixCmqrTtXMSPSYGqjhcX+6Q9ZLA42P2Ry YPK4v2oKq8eqgx+YApiiuGxSUnMyy1KL9O0SuDKWvWliKfjJWXHi6HOWBsbX7F2MnBwSAiYS fd8msHUxcnEICSxmkvi+vhHK2cgo8XHHYnYIZxeTRP+k3awgLSwC2hKd3+azgNhsAmoSH45+ BYpzcIgI6Epcv6wLEmYW0JdYP/EwM4gtLBAg8ezcLzCbUyBQYtnpi4wgNq+Au8Tbq21MEPN7 GCUaL1wFmy8KNOfQvz9sEEWCEidnPmGBGKouceATRDMz0A33b7axTWAUmIWkbBaSsllIyhYw Mq9ilE3JrdLNTczMKU5N1i1OTszLSy3SNdTLzSzRS00p3cQIDlVJnh2MZ954HWIU4GBU4uH9 MTE9Uog1say4MvcQoyQHk5Iob5NMRqQQX1J+SmVGYnFGfFFpTmrxIUYJDmYlEV53WaAcb0pi ZVVqUT5MSpqDRUmcV0KjMUJIID2xJDU7NbUgtQgmK8PBoSTBm6kA1ChYlJqeWpGWmVOCkGbi 4AQZzgM0XIoLZHhxQWJucWY6RP4Uo6KUOK8KSLMASCKjNA+uF5JKHARfMYoDvSLMGwhSxQNM Q3Ddr4AGMwENXpOdAjK4JBEhJdXAyPZ/hknhoy2J15aFXj6WfG3b9thJcy20vFh4XrX47xXg ql15fvn8HCe1fwfznW5YrF5x/HNBzpqnNfyRJ/+/lbuSbyKiE/j2zOcpd7nZss6Uh+5SPP3e ubXlwLQtlm//2bBmhTDt0ota83zt31mSnGKhJ8tTZp81v9n8If7KkSn5Pv2zlm58zajEUpyR aKjFXFScCAASMaf4AAMAAA== On Thu, 13 Jul 2017, Bart Schaefer wrote: > On Thu, Jul 13, 2017 at 3:45 PM, Anders Kaseorg wrote: > > Given a=3D(1 2 3), I would expect {$^a,4,5,6} to expand to 1 2 3 4 5 6,= but > > it doesn=E2=80=99t. Instead the 4 5 6 is duplicated for every element = of $^a >=20 > Your expectation is wrong. Brace expansion happens last of all > (except for globbing), so {$^a,4,5,6} is {1,4,5,6} {2,4,5,6} > {3,4,5,6}. This is documented. >=20 > Even if this happened in the order you expect, the way you've written > it would have given 1 4 1 5 1 6 2 4 2 5 2 6 3 4 3 5 3 6 because of the > meaning of $^a. The documentation for ${^spec} says =E2=80=9CInternally, each such expansion is converted into the equivalent l= ist for=20 brace expansion. E.g., ${^var} becomes {$var[1],$var[2],...}, and is=20 processed as described in Brace Expansion below.=E2=80=9D That would seem to support my expectation that {$^a,4,5,6} should become=20 {{1,2,3},4,5,6}, which expands to 1 2 3 4 5 6. > What you are after is simply {"$a",4,5,6}. That produces 4 words ("1 2 3" 4 5 6), and doesn=E2=80=99t generalize (e.g.= I=20 would expect {$^a,4,5,6}{x,y} =3D {{1,2,3},4,5,6}{x,y} =3D 1x 1y 2x 2y 3x 3= y=20 4x 4y 5x 5y 6x 6y). Anders