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

Fix for ${\var} oddity



On Thu, Dec 20, 2018 at 11:53 PM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> > > The \ is not removed before var expansion, ${\#} is not ${#}
> > > and \# is not a valid var name, nor is \ if this is being parsed
> > > as a substring match on ${\}
> > > so this should be a syntax error
> > > (at least in sh emulation mode).
>
> This one surprised me.  Seems to come down to this code in params.c:
>
> 2341        } else if (inbrace && inull(*s)) {
> 2342            /*
> 2343             * Handles things like ${(f)"$(<file)"} by skipping
> 2344             * the double quotes.  We don't need to know what was
> 2345             * actually there; the presence of a String or Qstring
> 2346             * is good enough.
> 2347             */
> 2348            s++;
>
> inull() is expected to match a quote there, but it happens to also
> match backslash.  Fix in another thread.

diff --git a/Src/subst.c b/Src/subst.c
index ff6750a..60eb333 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -2338,7 +2338,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int
                zerr("bad substitution");
                return NULL;
            }
-       } else if (inbrace && inull(*s)) {
+       } else if (inbrace && inull(*s) && *s != Bnull) {
            /*
             * Handles things like ${(f)"$(<file)"} by skipping
             * the double quotes.  We don't need to know what was



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