From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3658 invoked by alias); 3 Feb 2014 17:36:08 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 18380 Received: (qmail 10918 invoked from network); 3 Feb 2014 17:36:02 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Mon, 3 Feb 2014 18:36:00 +0100 From: Roman Neuhauser To: zsh-users@zsh.org Subject: destructuring assignment Message-ID: <20140203173600.GG14992@isis.sigpipe.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) hello, having an array such as declare -a partitions; partitions=( /boot:boot:512:fat:boot,legacy_boot :swap:10240:swap /:root:-:btrfs ) i'd love to iterate it like: for mountp name size fs flags in ...; do # 1st iteration # $mountp=/boot $name=boot $size=512 fs=fat flags=boot,legacy_boot # 2nd iteration # $mountp= $name=swap $size=10240 fs=swap flags= # 3rd iteration # $mountp=/ $name=root $size=- fs=btrfs flags= done i tried for ... in "${(@s.:.)partitions}", but that seems to join the array before applying the (s.:.), which is contrary to my expectations, but i may be misreading the manual (14.3.1: "[(@)] is distinct from *field splitting* by the `f`, `s` or `z` flags, which still applies within each array element.") this is what i see: roman@stick ~ 1026:0 > echo $ZSH_VERSION 5.0.2 roman@stick ~ 1027:0 > typeset -p foos typeset -a foos foos=(a1:a2:a3a,a3b,a3c b1:b2:b3 :c2:c3) roman@stick ~ 1028:0 > for a b c in "${(@s.:.)foos}"; do typeset -p a b c; done typeset a=a1 typeset b=a2 typeset c='a3a,a3b,a3c b1' typeset a=b2 typeset b='b3 ' typeset c=c2 typeset a=c3 typeset b='' typeset c='' and this is what i want: roman@stick ~ 1028:0 > for a b c in "${(???)foos}"; do typeset -p a b c; done typeset a=a1 typeset b=a2 typeset c=a3a,a3b,a3c typeset a=b1 typeset b=b2 typeset c=b3 typeset a='' typeset b=c2 typeset c=c3 -- roman