From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43733-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 085fc813 for ; Sun, 28 Oct 2018 04:54:41 +0000 (UTC) Received: (qmail 26826 invoked by alias); 28 Oct 2018 04:54:31 -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: List-Unsubscribe: X-Seq: 43733 Received: (qmail 23280 invoked by uid 1010); 28 Oct 2018 04:54:31 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f174.google.com 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(209.85.208.174):SA:0(-1.9/5.0):. Processed in 2.194322 secs); 28 Oct 2018 04:54:31 -0000 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=jQGeZBPO7EWkCBzA04Hn78mFKMoWfgw1SMG0dmlsCh0=; b=sIzvLFLgMsnPULkQUuppkrEvU1v/hFslMrejeE5Q8kSDDoLg/s5SZSsc3EL+AKdTVo pEKGSWiAh8/RsVGCRg4pR254DAKgEUak74UpfKdbd2/hMAF8Z8RLGA005xbF6WFEtKWE q6H7eh9hAmkGNXsotgnOUF2XlNOB+6wV/YS9oJGlbNAFX6eSsxdhio0OZmtYkWMpA5Lg /ng0ag31IyGy8FUg7CjYEZrOL7J9zIZ5FHu2a5cbKcArgsL24iQqkgYWJ2HQfhQTCaEa /rV6YQJpeO1rbEMvMf8+GELwxXvM+GCYW5M0076HVDq9EeKdAPUcTpQejrFXNDi2PZXz B0Ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=jQGeZBPO7EWkCBzA04Hn78mFKMoWfgw1SMG0dmlsCh0=; b=pl9OqpBgSOA6DSpCrnjQpbMh2YNXJEaNnxuFnyzkhFJ3V3vJNUv+PtGpDMr9l+IKlR s+ikroAJpB0cNP5W8g3aUhiohQTGf7jlmgOF8J0hJyqTxC8gA1kqwo40cjSNZ55WaGnM l4MTNRVtA/PZ8+CJ9WNIcZ6z19v3uPfMwRDfkODHOZq+OZybk3/p1qgPokFKn8n5m97G Xy6wWwgrM0MnVN0kHso8sn89RemEz0RGRpuHHV3X8u703CqjTePXbY+jwLh8XkzA1Jhv dn5jAqpURI2MK6VBLrJ5RwJotEuz/6PJ3aKdsrcyTxN7S1pZ0uM5VmxKZ6qIV7x/tI9/ I+wg== X-Gm-Message-State: AGRZ1gJeCtI34A2KmGyP8qlZU41XgIGH8w4p1ei/FHXnuwA2DZ9AG4X2 YBrtM1+5ZmNJ7xXrAvXj3NxznefmZsyzpwHk6h4tbz6nCd8= X-Google-Smtp-Source: AJdET5dZHE5o8B8Som+yG+j5MX80q5MCaGMERtLrX3mrf29Co1n751pdKFRUfPGk7xOrRonco8ot7Da/f+ZbiTy4qdw= X-Received: by 2002:a2e:529d:: with SMTP id n29-v6mr5967471lje.54.1540702464571; Sat, 27 Oct 2018 21:54:24 -0700 (PDT) MIME-Version: 1.0 References: <1BE52C46-161F-412B-A539-4B0EA87A2FCE@dana.is> In-Reply-To: <1BE52C46-161F-412B-A539-4B0EA87A2FCE@dana.is> From: Bart Schaefer Date: Sat, 27 Oct 2018 21:54:11 -0700 Message-ID: Subject: Re: Inconsistencies in "-quoting and @-splitting, could someone elaborate? To: dana Cc: Sebastian Gniazdowski , "zsh-workers@zsh.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Oct 27, 2018 at 5:34 PM dana wrote: > > On 27 Oct 2018, at 05:33, Sebastian Gniazdowski = wrote: > >I'm having problem in grasping, is this behavior: > >- "X-flag creates array, unless its result is a single element", and > >- "X-flag creates array even when double quoted without use of @" > > I don't know if it's accurate to say that they 'create an array' =E2=80= =94 they expand > to a list of zero, one, or multiple words (or elements, or arguments, or > whatever you want to call them), which you might then *put into* or (in c= ertain > parameter-expansion cases) *act on as* an array, but the result of the ex= pansion > is not an array per se. You're not wrong, but the documentation consistently refers to a word list occuring in parameter expansion context as "an array". To address Sebastian's question, the behavior of (s::) is historical. Because zsh passes expansions around by value rather than by reference, in the original implementation of nested expansions a single-element array value was indistinguishable from a scalar. This didn't change until 2015, when extra effort was made to retain the properties of a parameter across levels of nested expansion. However, the result of a split with (s::) is never a parameter (it's just an array value), so it kept the old behavior. This is true of anything that is considered "simple word splitting" (#11 in the "Rules" subsection of the parameter expansion docs), and also of the (z::) operation (rule #17). However, you'll never see the effect unless the array value is inside a nested expansion; if there is only a single level of expansion, double-quotes (rule #5) apply before splitting, so the result remains an array. To circumvent this historical behavior, the (@) and (A) flags are used to propagate array interpretation from an inner nesting to an outer one.