From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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=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 9eb89d0f for ; Thu, 12 Sep 2019 01:04:37 +0000 (UTC) Received: (qmail 9862 invoked by alias); 12 Sep 2019 01:04: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: 44755 Received: (qmail 17580 invoked by uid 1010); 12 Sep 2019 01:04:31 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f195.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25566. spamassassin: 3.4.2. Clear:RC:0(209.85.208.195):SA:0(-1.9/5.0):. Processed in 2.131173 secs); 12 Sep 2019 01:04:31 -0000 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.208.195 as permitted sender) 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; bh=DORykRaTo9ZbyVYkPyzFXuyfZp7hjZx4FB+7gYiERU4=; b=W9jjBZT3W58UmCGEKa9LxaEnwkZgnLXRAuutVpxbqeQZU3ujTjI1106dHBSKOMEmXz HvycSrpn/CFaIjAHrAlNwStPtWBEsI/+JHazBX6mh+ZWUpF33zg1272AWUp/2NyrCfQZ R10k4LofzQG14IePaJL7Iq/Uf3J1dnb+qSdDPt+oGjPkaPKryKdg6JFCpJKF2lRqENE4 a70b1RY1B5djhwRX+PmFGSyy8/RJTBD7ZzDPEPmPBNdkzjgCf/aIkxXBLTegSGrMB/Vv YF1xu3lFPe1g4Vf3uJViKW6jzCNgGCoU9/sggDrvizerBWdVR2u8tSjwBfWratfE7X8/ 0klQ== 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; bh=DORykRaTo9ZbyVYkPyzFXuyfZp7hjZx4FB+7gYiERU4=; b=TDJnpLiLAATvJb/pSxnNHn7HpVQwBPwQQXaywU0v18+a91KQkGG9xY4uXisu8btXxu EQOu4Cjpv5owbcTpojrRqftrv1zZSmr5OP1MgrVs598nnqztQFGapF6eL410rYTiEr0/ HFE1u7A1HdEG22UqzZR83FxnlT9AlW8QyVHMiBgOMv2SOUoBlag1lMwnzGI159tP8uC3 LTt66IRaWQHu6J5AbzUuXLq9ioPbfeE8//7UjYjglrpxeTr36RUxyqzRngsMbgb3uoz7 86nO5XA2iIe0sUU3M2ulxZWeYiLHRXoT80O2MQaRMGQQ5xKO6s5dhIabHyL+rTP8wf37 ++Pw== X-Gm-Message-State: APjAAAWqxNbFInqISEj8K6UCePHKRm+D801QdSOcXxpIr2kaKbmqBCdR kpaybFDZZpequ7OJau5K92R1/5eQ0JBoZpNCvIjJmw== X-Google-Smtp-Source: APXvYqxcIJwTe68110hKvcuL6ho5tF7AGg3jZ8S1XS/dlAMUA/c7eVqwu/xJcyTbY3AHXGzl1d3eKYkgbeeJCGw/A3E= X-Received: by 2002:a05:651c:202:: with SMTP id y2mr25435442ljn.4.1568250233850; Wed, 11 Sep 2019 18:03:53 -0700 (PDT) MIME-Version: 1.0 References: <20190907150741.jwztdoslrvk5j7nk@chaz.gmail.com> <20190907201954.dn2nve65wqk4muvc@chaz.gmail.com> In-Reply-To: From: Bart Schaefer Date: Wed, 11 Sep 2019 18:03:41 -0700 Message-ID: Subject: Re: [PATCH] Support the mksh's ${|func;} substitution To: Sebastian Gniazdowski Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" On Wed, Sep 11, 2019 at 5:09 PM Sebastian Gniazdowski wrote: > > So you've implemented ${|code;} for mksh? Good grief, no. I have never even (knowingly) USED mksh. I just said that IF it had been me, I probably would have made a different syntax choice. > On Tue, 10 Sep 2019 at 21:38, Bart Schaefer wrote: > > > > I'm writing by analogy to the (e) glob qualifier. Consider: > > > > % touch 'echo HELLO WORLD; reply=HERE' > > % print e*(e^'eval $REPLY'^) > > HELLO WORLD > > HERE > > Ok, but this could use ...RLD; REPLY=HERE'. The use of reply is just > to simplify, i.e. to use different vars for the (x) embedded code and > for the substitution code? Again, by analogy to the glob qualifier -- the input ($REPLY) is a scalar, the output ($reply) is an array (which might or might not get string-ified by double-quoting). In an (e) glob, REPLY is set to each possible file name in turn, but $reply can provide multiple names to the final result. I'm assuming you want ${(x...)array} to apply to each array element in turn, not to the entire array at once, so again REPLY is a scalar (each array element) but could be replaced by multiple elements in $reply. > Ahso. So the ${(x^'eval $REPLY'^)var} in the end could be ${(x^'eval > func^):-} ? I.e. the code to evaluate would be provided within the (x) > delimiters, and the connection with REPLY <-> substitution value (i.e. > $var or :-string) would be additional? I think you grasped it, yes. Whether the syntax ${(x+func)...} would call "func" once for each array element (again by analogy to glob (e+func)) would be an implementation choice. Too bad (x) for globs and (e) for parameters already have other meanings, so there's no way to make them use the identical key character. > > > I think that the (x) flag should be at the top of the list, first. > > > > That can't be right. > > Ok, I've did hurry too much. The :- is point 7. This sounds more sensible.