From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43738-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 c1b71054 for ; Sun, 28 Oct 2018 15:46:08 +0000 (UTC) Received: (qmail 11815 invoked by alias); 28 Oct 2018 15:45:58 -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: 43738 Received: (qmail 13128 invoked by uid 1010); 28 Oct 2018 15:45:58 -0000 X-Qmail-Scanner-Diagnostics: from mail-oi1-f180.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.180):SA:0(-2.0/5.0):. Processed in 1.669354 secs); 28 Oct 2018 15:45:58 -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=TsDHC9u6zIXukghDdmAtT7FlIic9/StLXn8IYk/PC4k=; b=TeSKJd44soEw0Ov4t2ZEjSwnHEo7J0TzkhbCy4snKp3LFh0uRzwhqq0PM5S+EiLr/O rV3pB5FnsQ42IXhJXxRKSNWaw7JaA5lOWfWH+2KzLICTNtC7d7+Q0VEFmxH64AxUIW0o Cl1lrMx+Gb2ZgNfGsWmrvZl/H3r6Z1EUtMqJVu0W8FrW4DO6Foi27L08RCxlc/DRk6Uk 6G790oNUau7HmQhdf3Veb7xzei5AX+yegmLqfKE0CWPMWGT5QapiR1+0QjSVXpGXHeKA w2BdH01sR3QDZrrCZKJ0RKAB5tmlzuC3yqFyeE2wr/UlZZob9vdg/2OP4mDuD9vOnWiq K6TQ== 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=TsDHC9u6zIXukghDdmAtT7FlIic9/StLXn8IYk/PC4k=; b=nXqLKxqP9xM3uzk5a4Aa5ZYBDYKZsv0LjU+4lurAcOMIplXZklcvudaNDzvQz8BjbE 1W0VTwBQ0oMZZreZAKw5J551H+xOKiVpmggiy8jqgAM7VoFRkbKxnNk6qwMU6UEReBVE VZSPU96YtoSMEY/++kxrcoyCY8bM+N76gK6BaVOYWsj3S15/6jedACYaRC8vfhZn0Z50 4MjtnrWm6h9M2K5FTTu+4YaCT+N3HxxwULacy52gEuVIF+iz4jIawwUlirckoHQQbK+5 MegBuNJYennfc2nCd79OjP9SLV11IJRUfCCi5jbxuA03NlQauuDjWQdTrDb20He/dt1t Jenw== X-Gm-Message-State: AGRZ1gJe0q04YWhD2/e4DbxsNPbvY0OyBsqOk+ko7PLvvx0qEJ1be0lO 4rHYjt4G7FZ7dXzaZYp39uw81vkteE+6xJ0qpGtwOw== X-Google-Smtp-Source: AJdET5fkLFMcYGR3lXzJZNhK935wa9bJIQf0fuutmT3PYs/pliyIsnsLt6mq35PciyRL0b0E9UhMhfxOCRvRaQArfMA= X-Received: by 2002:aca:afd0:: with SMTP id y199-v6mr2529533oie.322.1540741553350; Sun, 28 Oct 2018 08:45:53 -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:45:41 +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 PS. I'm not examining this to induce some changes in Zsh =E2=80=93 I think every project can have bunch of its distinct traits, non-symmetrical =E2=80= =93 but to gain more knowledge and maybe get information about other flags like z&s, to provide a possibly clear paragraph about exceptions in the document "Zsh Native Scripting Handbook". It currently follows "@ is double-quoted splitting" based on completion-description and some insight/revelations, and it's too optimistic, doesn't describe exceptions. On Sun, 28 Oct 2018 at 16:41, Sebastian Gniazdowski wrote: > > 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 scala= rs. > -- > Sebastian Gniazdowski > News: https://twitter.com/ZdharmaI > IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin > Blog: http://zdharma.org --=20 Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org