From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10857 invoked by alias); 7 Sep 2012 14:42:10 -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: 17230 Received: (qmail 8558 invoked from network); 7 Sep 2012 14:41:58 -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,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120907074136.ZM22145@torch.brasslantern.com> Date: Fri, 07 Sep 2012 07:41:36 -0700 In-reply-to: <29236168-55B5-4555-9ACA-B1D21D345EA9@biskalar.de> Comments: In reply to Sebastian Stark "double quoted expansion question" (Sep 7, 2:31pm) References: <29236168-55B5-4555-9ACA-B1D21D345EA9@biskalar.de> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-users@zsh.org Subject: Re: double quoted expansion question MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Sep 7, 2:31pm, Sebastian Stark wrote: } } Dear zsh users, } } What I would like to understand here is why the output changes the way } it does when I add double quotes around my expression. I would expect } the same output as without. If anybody could shed some light please, I } guess it's just something obvious I cannot see. It may help to read the "Rules" subsection in the "Parameter Expansion" section of the zsh manual. Note that "double quoted joining" happens at step 5, before "modifiers" [including the //* / replacement] at step 7. Although "forced splitting" (the s and f flags) doesn't happen until step 16, "nested substitution" happens at step 1, so your innermost ${(f)servers} still happens before double quoted joining is done, and it's the result of that split that is then joined on spaces, causing //* / to do something you don't expect. So what you need to do is tell zsh not to join that array, which you do by adding the @ flag at the nesting level where the join would happen: print "${(s:,:uo)${(j:,:)${(@)${(f)servers}//* /}}}" Also note that "forced joining" (the j flag) is applied at step 5 when the substitution is in double quotes, but not until step 10 when unquoted. That matters here only to explain why you need only one @ flag. BTW, you don't need // there; there is only one space in each array element after ${(f)servers}, so ${(@)${(f)servers}/* /}} is enough.