From: Bart Schaefer <schaefer@brasslantern.com>
To: "Lawrence Velázquez" <larryv@zsh.org>
Cc: zsh-workers@zsh.org
Subject: Re: [PATCH] Support the mksh's ${|func;} substitution
Date: Tue, 4 Jul 2023 22:32:34 -0700 [thread overview]
Message-ID: <CAH+w=7aDHvJV6K=Znbur=vw8ASt-MpKWgBpUm9CHT_akkgg9sg@mail.gmail.com> (raw)
In-Reply-To: <e27c46cc-eeca-4f90-a5b1-d1f0f1fb0743@app.fastmail.com>
On Tue, Jul 4, 2023 at 11:54 AM Lawrence Velázquez <larryv@zsh.org> 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.
next prev parent reply other threads:[~2023-07-05 5:33 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 14:46 Sebastian Gniazdowski
2023-07-04 1:55 ` Bart Schaefer
2023-07-04 18:53 ` Lawrence Velázquez
2023-07-05 5:32 ` Bart Schaefer [this message]
2023-07-05 6:30 ` Bart Schaefer
2023-07-06 1:39 ` Bart Schaefer
2023-07-06 2:27 ` Mikael Magnusson
2023-07-06 4:00 ` Bart Schaefer
2023-07-18 3:14 ` Bart Schaefer
-- strict thread matches above, loose matches on Subject: below --
2019-09-06 0:52 Sebastian Gniazdowski
2019-09-06 0:54 ` Sebastian Gniazdowski
2019-09-06 23:16 ` Sebastian Gniazdowski
2019-09-07 12:16 ` Daniel Shahaf
2019-09-07 15:07 ` Stephane Chazelas
2019-09-07 18:09 ` Sebastian Gniazdowski
2019-09-07 20:19 ` Stephane Chazelas
2019-09-07 21:19 ` Sebastian Gniazdowski
2019-09-10 2:20 ` Sebastian Gniazdowski
2019-09-10 5:29 ` Bart Schaefer
2019-09-10 18:21 ` Sebastian Gniazdowski
2019-09-10 19:38 ` Bart Schaefer
2019-09-12 0:08 ` Sebastian Gniazdowski
2019-09-12 1:03 ` Bart Schaefer
2019-09-12 2:06 ` Sebastian Gniazdowski
2019-09-12 5:35 ` Bart Schaefer
2019-09-12 6:00 ` Sebastian Gniazdowski
2019-09-12 6:55 ` Bart Schaefer
2019-09-13 20:28 ` Sebastian Gniazdowski
2019-09-13 21:33 ` Bart Schaefer
2019-09-13 21:36 ` Bart Schaefer
2019-09-14 0:41 ` Sebastian Gniazdowski
2019-09-14 0:44 ` Sebastian Gniazdowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7aDHvJV6K=Znbur=vw8ASt-MpKWgBpUm9CHT_akkgg9sg@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=larryv@zsh.org \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).