From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2125 invoked by alias); 3 Feb 2014 22:09:04 -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: 18382 Received: (qmail 23043 invoked from network); 3 Feb 2014 22:09:00 -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=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=HhCCgTKPqiDCFR5CD/UkWSnui42zbceEU9qMYzqJPIQ=; b=H/Mlz7DpxX27eA9Q2TVrAh0KWN7Ls2KtfNUzhG/l8YswRJxVBcTHe2WcxGffbTF5IG dfz8Ia1S02C5sLaJPek3cpZkwIoBanC+hofvxysasAApDLJyUHEPcZl/M4mlqSBja3Mw E5Ot4AWyqo7f+AfrE/NEo6yjC1VLBz9+xeN3g1Q7KWQQlBE8w4qktmzWXzswdltsGg0T 6kx2sWVS/qEHZTJtl8sWJAEOm/0r6NNcQPbSFDjACd3vTAmFsfJV4wN/4uk3q6lXmKCY B/VeDkOd1MB8uc3HNkMITfEDvESOUD3lanY70JImDb5Up7C0SEBSuixD61HdSQ8M0E00 Sfpg== X-Gm-Message-State: ALoCoQkW6mORVl3bS7iA64NnugbGas8LhGbvtY4IO2lOUM3s0e/Q6veFeBW6Y5otT3cjQLt7wYPP MIME-Version: 1.0 X-Received: by 10.152.161.234 with SMTP id xv10mr2935928lab.41.1391465336617; Mon, 03 Feb 2014 14:08:56 -0800 (PST) In-Reply-To: <20140203180049.775877d9@pwslap01u.europe.root.pri> References: <20140203173600.GG14992@isis.sigpipe.cz> <20140203180049.775877d9@pwslap01u.europe.root.pri> Date: Mon, 3 Feb 2014 14:08:56 -0800 Message-ID: Subject: Re: destructuring assignment From: Bart Schaefer To: Zsh Users Content-Type: multipart/alternative; boundary=001a11345a081b4aa304f187c51d --001a11345a081b4aa304f187c51d Content-Type: text/plain; charset=ISO-8859-1 On Mon, Feb 3, 2014 at 10:00 AM, Peter Stephenson wrote: > On Mon, 03 Feb 2014 18:36:00 +0100 > Roman Neuhauser wrote: > > having an array such as > > > > declare -a partitions; partitions=( > > /boot:boot:512:fat:boot,legacy_boot > > :swap:10240:swap > > /:root:-:btrfs > > ) > If you were to put a trailing colon on the partitions with no mount flags, you'd have the same number of colons in each array element, which might make some other things easier (as PWS mentioned). > for mountp name size fs flags in ...; do > Given the trailing colons to create empty flags fields for the lines that do not have flags, you can do for mountp name size fs flags in "${(@s.:.)${(j.:.)partitions}}" However, I'd still prefer Peter's nested loops. > for line in $partitions; do > for mountp name size fs flags in "${(@s.:.)line}"; do > print mountp=$mountp name=$name size=$size fs=$fs flags=$flags > done > done > Another option is while IFS=: read mountp name size fs flags; do # ... done <<<${(F)partitions} That should work even without the trailing colons, but could be tricky if you need standard input inside the loop body. --001a11345a081b4aa304f187c51d--