From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 26063 invoked from network); 5 Jul 2023 05:33:08 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 5 Jul 2023 05:33:08 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1688535188; b=RW28Tf7lLp2xt8q7PWDZrBmL5gjlcOslK/EsTCz06BiqInxHwhysDJnuAcRWUwqhHWiEsNktkZ Zx+Vc9HXbj/1O8gbiaEDsrZDsv6B7J8cB6e3W2T+PJv4rt2Jtn+9lvGJTNFzYVeItIsR9iV5AP CEH3UzI0coxl7T/+Gd6lrkls1PTE+5vd/fBOFhGzZj2dImgOt6sCTfBOZ+5Ar5sHdHysabAQvM NWAsgCfhQu8ybBVtLYmyL8NV417OC9JQoxDfMJTAH4ubXbZRKkyqM1Nhf93NwQnPV+5MgLDM41 4LvUX0ogERnoMA9euPfIobCPEUt65REcfUh6DCy4tApV/Q==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1688535188; bh=Dyx8oJ3dtKM6Bato7t8v56xf0f2LRC+E76aIylNMjuc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:In-Reply-To:References:MIME-Version:DKIM-Signature: DKIM-Signature; b=RpJs6pOyZM21SEQkhd3ZbFGusRtqDY8UANhr4AYKuwtKvaJjeX4tifLOoZPBgJmPg8zYLl6a4E bm1K41LlHZuCeItQRJmKFNZk7jQzmzGEvTDnUz+7HS1aQD6ehqbne/VNbjWr2ObGbHkSCaFxKg LVJbgjH+q3JPAe10b0iFUsxTEXlpkL7GoSb+pFZnbCvxbD8M0JGHQAQsjh6W6My3Cw7fp91LOE uywADwlwZ1mR83m9O4p9Cgfh70mw0/YgRw8fjeLbXjDjeOT9VvtHKJVmr/fHr5a/DJ6MUTpKhE A5NUtUxFIY+F68sPb7Pd9fSAl6kOV2iercJ/c01niK9XGg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To:References: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=q55LCzwfYHciU1TdiWi/PMMjI62cnKXWaC8nAING66E=; b=Kl4OIBq8UXKT2chAq+6qovMYWU zkG3+tfx1CeC2zXl1Ty/pgj1CMC+pL/u8NAcIgx49cYCwUD26L/2Wzue7BqZ2jDisI8J1bnSU6Foe I+ltd5ooNznH9c8VdlIXtjhu/gHu6nyLptwdPIfblA9+Cc5OGCPGGPNJ+fOJ/PR7kPXqfr2fmgJmE 52+wXKHHhUpULn1ANiT8Z9ZGpTFIU+FqOiLi0TY6FuYOTE3OF5KA0sv/yXTjD4sV0t27Ty8/LwEJ4 Ugb6gqG1XHgVLo7/dEp9DL8MHT6A93fV0/WMirNyBeAdk1BYRAcnCjI32lJnnSXQS+/lxDapdGdTh U3sRWbCw==; Received: by zero.zsh.org with local id 1qGv8V-0000nx-Aa; Wed, 05 Jul 2023 05:33:07 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f48.google.com) smtp.remote-ip=209.85.218.48; dkim=pass header.d=brasslantern-com.20221208.gappssmtp.com header.s=20221208 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f48.google.com ([209.85.218.48]:42209) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1qGv8B-0000UN-Jm; Wed, 05 Jul 2023 05:32:52 +0000 Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-9939fbb7191so60105266b.0 for ; Tue, 04 Jul 2023 22:32:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20221208.gappssmtp.com; s=20221208; t=1688535166; x=1691127166; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=q55LCzwfYHciU1TdiWi/PMMjI62cnKXWaC8nAING66E=; b=J+afYHynKOD/sRt86gsa4IydaRITNMK5zDdHPB/+pdSpnTqSA0U4h5RG/MP8+MaWuv VRHHETxyi6hV2uULlk49aFp9IlfEUjQnscE8+hmFa2oxOJs82XQp4UMOQEUCbd/kuRpB ujuShHnW4YuKXwe4DL3T/fMUcCeNJRVef5TVrU+SM+pUdCl9vvRKsgvGSZEP3aiCwAip lawFlC75MSGrOtYJsHhUI+ImOy8WBy2l8jCGlq7uHuKSv42scpPuG5tcU0smNrqET2Yg Wb1MIorgAaIjKdRndGi+xvvbiBm/cUpX8V30RzU96J9QQ/MXt+CqFzTgoOVMpD4KWD/9 45jQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688535166; x=1691127166; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q55LCzwfYHciU1TdiWi/PMMjI62cnKXWaC8nAING66E=; b=Cmea1MDly7vQWffvhAdod/1lHVYjrhBDm/R3QU+xRfDxlltr2Oaq1i4Cq9HHPwdv34 RhOibaZjE3PywVP5Vs2fnwEQKy8d0kWBaBlRfwKZvQxtKKZ3rnmeLrGIPo/IB2bKH2e9 PNE5JA61VyuioCkjooqA44YITWWL+yOfoLaggkaaVbPAXLTkaBZNstnj+PozWpfQfq80 0NFmZoo8SGNcsMZuKrEZLRXZHpDtjhuMhuZ2Yw5S1f7cf5IaDHh4GnKJG5bhH+5OxZ5Z oR10ThiohsXlaY4YrlqFggD4bGa9KWP02L03BO5d3BoFkvet+uJLAZGVxV5o/i498tKj t2Cw== X-Gm-Message-State: ABy/qLa4O7aKHl4vT7JFU7Cp9UxSpFLSAjIq9wSeSKLNORELIkOqCebk MLcQDjIS/x6RVqjEY6On+bmfUuHZS7pyZqMbedfZgw== X-Google-Smtp-Source: APBJJlF0CgRUDWfIlcdwU+a8M2MkenSJsidUIYH0+I+XG0zJzraCg0XwFcJ5gx5quUAI08V6s0+gmpZWnraOoqAzC3k= X-Received: by 2002:a17:906:7a56:b0:982:4b35:c0b6 with SMTP id i22-20020a1709067a5600b009824b35c0b6mr1253967ejo.1.1688535166058; Tue, 04 Jul 2023 22:32:46 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Tue, 4 Jul 2023 22:32:34 -0700 Message-ID: Subject: Re: [PATCH] Support the mksh's ${|func;} substitution To: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 51902 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Tue, Jul 4, 2023 at 11:54=E2=80=AFAM Lawrence Vel=C3=A1zquez wrote: > > For reference/comparison, a similar feature was recently added to > bash's devel branch: > > https://lists.gnu.org/archive/html/bug-bash/2023-05/msg00042.html Hmm, some interesting things from there -- -- REPLY is treated as a local, i.e., it's value gets saved and restored around the substitution, and it's implied mksh does the same. Zsh never does that anywhere; are there other places (in other shells) where REPLY implicitly behaves like that? -- "local" works inside the substitution as it would inside a function body, but $@ refers to the calling environment. -- "return" also behaves as if in a function body. -- Robert Elz noticed that mksh will allow ${|foo} rather than ${|foo;} and Chet calls that a bug ... I suspect both zsh and mksh consider allowing { foo } rather than { foo; } to be a feature, and this "bug" is merely a reflection of that? -- it's really not possible to implement ${(command)} in zsh because ${(flags)param} is already valid syntax, and this would break some scripts that try to be zsh and bash at once. Chet says he's going to require ${ (command); } instead, though. -- ${ command; } is implemented using an anonymous tempfile rather than something like Perl's IO::String. (Whew.) The first three of those are implementable within the structure of the patch from workers/51898 although it's a little messy because of the multiple "return" points in paramsubst(). The anonymous tempfile for the last one requires some extra stuff. The trick with "local" vs. $@ actually might address some of the points raised by Oliver in past discussion about the "private" module.