summaryrefslogtreecommitdiff
path: root/footobar.c
diff options
context:
space:
mode:
authortjg <tjg>2001-10-02 13:00:35 +0000
committerToby Goodwin <toby@paccrat.org>2015-05-16 21:23:19 +0100
commita11a8d312e531231ed4d284f3cd129ccf2de2a43 (patch)
treec007353858e83d5056bf06632a1a2de09a97fdcb /footobar.c
parent38da49b97b529815045c23cfef4820a56179eebb (diff)
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.
Diffstat (limited to 'footobar.c')
-rw-r--r--footobar.c10
1 files changed, 6 insertions, 4 deletions
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;
}