From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43737-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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,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 03831035 for ; Sun, 28 Oct 2018 15:41:59 +0000 (UTC) Received: (qmail 14220 invoked by alias); 28 Oct 2018 15:41:44 -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: 43737 Received: (qmail 29174 invoked by uid 1010); 28 Oct 2018 15:41:44 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi1-f172.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.167.172):SA:0(-2.0/5.0):. Processed in 1.772006 secs); 28 Oct 2018 15:41:44 -0000 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=Li58qpoGaq0YNqt4L/greKhg4N0GB857UE8ha7KnIuc=; b=cLZ17nHy6s7aKlWgIKtI018Jez1lmfRTcKLnSz3aRzcZYyZi0TeJUYtJgxEmmHSxfo cD1c2bd+Bqj7R1GuCt7CkLPhqoliUgDLG+N94NHet6mcEeTPrgg9RaoR6pvP+tB3xH+b a0uSLHuo+A0OCi/8wAmLn6GrqySIDRWOEWJmY7Y/xuMLu4xIP0Kf8yq0YPZmm8qnKjZe G3qWSgmxadtKcZWNBbTmvjyHuESJq48ZIm8EMkmkYevlrgkRyJul+PQZdsWP48pcutpW SBrCEbW5rh95wQlhvxgZW8Uy7VPuGLbnn586jpOahci4Pjj+VdVqJV0dV0ANtGwB5z9j JV3w== 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:content-transfer-encoding; bh=Li58qpoGaq0YNqt4L/greKhg4N0GB857UE8ha7KnIuc=; b=bARmmtpiCuodrVB8mCeiYh0c4Ztt9HDfLrstVQ4vbZGX/a7JFeeBkRCzXIBaIEeejZ wnUOiAs8dosVO09ID1KedXWXR/9/6Npxqek/N+tlE1ltO9m/F1eGdR1qW8WszKoX4btf 2hHh6BTbyyAWMkSmE5C7DaJtvPI7VhJPVbZoOsUk74tuEFwqrNRivIuM5FN3TQglVR0O xvo1u8RvFzemxNzGqbx3KSiADITGNHug0Wc1cgHRZknqfuS0Ogldvgt3kOFGppC9nI9B MW6wssCEE9eOb/oJDzH+Ji3h0DIZf1EuDCkgiO4EGeEUmPgvCd+lBCoFAgYNABmD2H6v NFtA== X-Gm-Message-State: AGRZ1gIkFqGZAqfjc30X4c90TLKkQU/cYYtdQQ1RMfOctXhybDAvmnZv hqXCCZtpbTmfUsccllQkK1M6VfAzV7EIqlV1aNWgKmHr X-Google-Smtp-Source: AJdET5fNw5JLzib/Nxjp3dVOIWm99hzOeIG+LuWbUYOTO0AO3pZB42rQQJEL3MQAYE33L3MGp0t5SZAT/B+TSYtcsMU= X-Received: by 2002:aca:aa84:: with SMTP id t126-v6mr6933742oie.218.1540741299022; Sun, 28 Oct 2018 08:41:39 -0700 (PDT) MIME-Version: 1.0 References: <1BE52C46-161F-412B-A539-4B0EA87A2FCE@dana.is> In-Reply-To: From: Sebastian Gniazdowski Date: Sun, 28 Oct 2018 16:41:26 +0100 Message-ID: Subject: Re: Inconsistencies in "-quoting and @-splitting, could someone elaborate? To: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, 28 Oct 2018 at 12:54, Sebastian Gniazdowski wrote: > Despite array is single element, @ splits it into array type. (s::) > and (z) behave differently for single-element result, that is one > (maybe subjective) inconsistency, and for the second =E2=80=93 @ doesn't = help > (ie. (z@) still doesn't return as an array), that's second > inconsistency IMO. I've forgot one inconsistency and thought that a more explicit description of them (of the (subjective) inconsistencies) can be provided: 1.a) array=3D( "foo" ); print "${#${(@)array}}" -> 1 1.b) words=3D"singleword"; print "${#${(z)words}}" -> 10 1.description) with @, it is possible to obtain "always-array" behavior, while (z) and (s::) have exceptions and not always return arrays (one could think that if a flag takes the responsibility for splitting in string-context ("-quoted), then that it will mimic the first tool to do that, the @) 2.a) the same as 1.a 2.b) words=3D"singleword"; print "${#${(z@)words}}" -> 10 2.description) if ${(@)array} makes single-element quoted array back an array again, then shouldn't @ acting on single-element data (Bart said it's not array) returned by (z)/(s::) also make it an array again? 3.a) array=3D( "foo" "bar" ); print -rl "$array" -> foo bar # both elements in one line, signaling the expected "scalarization" 3.b) words=3D"two words"; print -rl "${(z)words}" -> foo\nbar # two lines, with one word each, indicating non-scalar result 3.c) words=3D"two words"; print -rl "${(s: :)words}" -> foo\nbar # --- " --= - 3.description) Basically, the general method of Zshell to obtain scalars with no splits =E2=80=93 double-quoting =E2=80=93 isn't followed by= (z) and (s::) flags. The manuals often elaborate about some situations and "-quoting like if this would be a general "scalarization" method guaranteed by Zsh design. Hard to give examples, but maybe this one: ${name:|arrayname} ... If the substitution is scalar, either because name is a scalar variable >>or the expression is quoted<<, the elements of arrayname are instead tested against the entire expression. Above slightly suggests "-quoting as a general method for obtaining scalars= . --=20 Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org