Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Nofork ${{var}...} edge cases



On Sat, May 31, 2025 at 2:10 AM Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
>
> I would argue that ${ foo} and ${ foo } should behave exactly the
> same

Ksh "${ foo}" is an incomplete parse, "${ foo} }" runs "foo}".

Zsh tokenizes differently so it can't emulate that, but I thought I
had it requiring that last space.

Without more major parser surgery the only alternative for omitting
the last space is "bad substitution" so I suppose it should just
behave the same.

> but also, I don't see a difference currently.

Hm, it is taking part of the ${{} ...} code branch but then it's also
going into a later ${ ... } branch.  I think it got that way because I
was thinking about that "Future?" idea in the comment (see below).

This is the easiest fix.  Doc update will have to come later, unless
someone else wants a stab at it.

diff --git a/Src/subst.c b/Src/subst.c
index a079672df..d0f2a1b45 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2021,7 +2021,7 @@ paramsubst(LinkList l, LinkNode n, char **str,
int qt, int pf_flags,
         /* Future?  Expose global value of $REPLY if any? */
         /* if (rplyval) setsparam("REPLY", ztrdup(rplyval)); */
         } else if (inblank(inchar)) {
-        rplypm = createparam(".zsh.cmdsubst",
+        rplypm = createparam((rplyvar = ".zsh.cmdsubst"),
                      PM_LOCAL|PM_UNSET|PM_HIDE|
                      PM_READONLY_SPECIAL);
         if (rplypm)




Messages sorted by: Reverse Date, Date, Thread, Author