From a11a8d312e531231ed4d284f3cd129ccf2de2a43 Mon Sep 17 00:00:00 2001 From: tjg Date: Tue, 2 Oct 2001 13:00:35 +0000 Subject: Bug: it's no longer possible to use parentheses to sneak a word that needs quoting past the "quoting detector", so `fn x { echo $(x.y) }' now works both in the current rc and its descendants. --- footobar.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'footobar.c') diff --git a/footobar.c b/footobar.c index e359de8..a94ab39 100644 --- a/footobar.c +++ b/footobar.c @@ -46,7 +46,9 @@ static int defaultfd(int op) { /* convert a function in Node * form into something rc can parse (and humans can read?) */ static bool Tconv(Format *f, int ignore) { + bool dollar = f->flags & FMT_altform; Node *n = va_arg(f->args, Node *); + if (n == NULL) { fmtprint(f, "()"); return FALSE; @@ -72,7 +74,7 @@ static bool Tconv(Format *f, int ignore) { case nForin: fmtprint(f, "for(%T in %T)%T", n->u[0].p, n->u[1].p, n->u[2].p); break; case nVarsub: fmtprint(f, "$%T(%T)", n->u[0].p, n->u[1].p); break; case nWord: - fmtprint(f, quotep(n->u[0].s) ? "%#S" : "%S", n->u[0].s); + fmtprint(f, quotep(n->u[0].s, dollar) ? "%#S" : "%S", n->u[0].s); break; case nCount: case nFlat: case nVar: { char *lp = "", *rp = ""; @@ -83,9 +85,9 @@ static bool Tconv(Format *f, int ignore) { switch (n->type) { default: panic("this can't happen"); break; - case nCount: fmtprint(f, "$#%s%T%s", lp, n0, rp); break; - case nFlat: fmtprint(f, "$^%s%T%s", lp, n0, rp); break; - case nVar: fmtprint(f, "$%s%T%s", lp, n0, rp); break; + case nCount: fmtprint(f, "$#%s%#T%s", lp, n0, rp); break; + case nFlat: fmtprint(f, "$^%s%#T%s", lp, n0, rp); break; + case nVar: fmtprint(f, "$%s%#T%s", lp, n0, rp); break; } break; } -- cgit v1.2.3