4 char nl='\n'; /* change to semicolon for bourne-proofing */
10 pdeglob(io *f, char *s)
25 default: pfmt(f, "bad %d %p %p %p", t->type, c0, c1, c2);
27 case '$': pfmt(f, "$%t", c0);
29 case '"': pfmt(f, "$\"%t", c0);
31 case '&': pfmt(f, "%t&", c0);
33 case '^': pfmt(f, "%t^%t", c0, c1);
35 case '`': pfmt(f, "`%t", c0);
37 case ANDAND: pfmt(f, "%t && %t", c0, c1);
39 case BANG: pfmt(f, "! %t", c0);
41 case BRACE: pfmt(f, "{%t}", c0);
43 case COUNT: pfmt(f, "$#%t", c0);
45 case FN: pfmt(f, "fn %t %t", c0, c1);
47 case IF: pfmt(f, "if%t%t", c0, c1);
49 case NOT: pfmt(f, "if not %t", c0);
51 case OROR: pfmt(f, "%t || %t", c0, c1);
54 case PAREN: pfmt(f, "(%t)", c0);
56 case SUB: pfmt(f, "$%t(%t)", c0, c1);
58 case SIMPLE: pfmt(f, "%t", c0);
60 case SUBSHELL: pfmt(f, "@ %t", c0);
62 case SWITCH: pfmt(f, "switch %t %t", c0, c1);
64 case TWIDDLE: pfmt(f, "~ %t %t", c0, c1);
66 case WHILE: pfmt(f, "while %t%t", c0, c1);
74 pfmt(f, "%t %t", c0, c1);
79 pfmt(f, "%t%c%t", c0, nl, c1);
80 else pfmt(f, "%t", c0);
82 else pfmt(f, "%t", c1);
90 pfmt(f, "for(%t", c0);
92 pfmt(f, " in %t", c1);
97 pfmt(f, "%Q", t->str);
98 else pdeglob(f, t->str);
102 pfmt(f, ">[%d=%d]", t->fd1, t->fd0); /* yes, fd1, then fd0; read lex.c */
104 pfmt(f, ">[%d=]", t->fd0);
118 pfmt(f, "[%d]", t->fd0);
125 pfmt(f, "[%d]", t->fd0);
133 pfmt(f, "%t=%t", c0, c1);
141 pfmt(f, "[%d]", t->fd0);
143 else pfmt(f, "[%d=%d]", t->fd0, t->fd1);
150 pcmdu(io *f, tree *t) /* unambiguous */
158 default: pfmt(f, "(bad %d %p %p %p)", t->type, c0, c1, c2);
160 case '$': pfmt(f, "($ %u)", c0);
162 case '"': pfmt(f, "($\" %u)", c0);
164 case '&': pfmt(f, "(& %u)", c0);
166 case '^': pfmt(f, "(^ %u %u)", c0, c1);
168 case '`': pfmt(f, "(` %u)", c0);
170 case ANDAND: pfmt(f, "(&& %u %u)", c0, c1);
172 case BANG: pfmt(f, "(! %u)", c0);
174 case BRACE: pfmt(f, "(brace %u)", c0);
176 case COUNT: pfmt(f, "($# %u)", c0);
178 case FN: pfmt(f, "(fn %u %u)", c0, c1);
180 case IF: pfmt(f, "(if %u %u)", c0, c1);
182 case NOT: pfmt(f, "(if not %u)", c0);
184 case OROR: pfmt(f, "(|| %u %u)", c0, c1);
187 case PAREN: pfmt(f, "(paren %u)", c0);
189 case SUB: pfmt(f, "($sub %u %u)", c0, c1);
191 case SIMPLE: pfmt(f, "(simple %u)", c0);
193 case SUBSHELL: pfmt(f, "(@ %u)", c0);
195 case SWITCH: pfmt(f, "(switch %u %u)", c0, c1);
197 case TWIDDLE: pfmt(f, "(~ %u %u)", c0, c1);
199 case WHILE: pfmt(f, "(while %u %u)", c0, c1);
202 pfmt(f, "(arglist %u %u)", c0, c1);
205 pfmt(f, "(; %u %u)", c0, c1);
208 pfmt(f, "(words %u %u)", c0, c1);
211 pfmt(f, "(for %u %u %u)", c0, c1, c2);
215 pfmt(f, "%Q", t->str);
216 else pdeglob(f, t->str);
220 pfmt(f, "(>[%d=%d]", t->fd1, t->fd0); /* yes, fd1, then fd0; read lex.c */
222 pfmt(f, "(>[%d=]", t->fd0); /*)*/
237 pfmt(f, "[%d]", t->fd0);
244 pfmt(f, "[%d]", t->fd0);
248 pfmt(f, "HERE %u)", c1);
250 pfmt(f, "%u %u)", c0, c1);
253 pfmt(f, "(%u=%u %u)", c0, c1, c2);
259 pfmt(f, "[%d]", t->fd0);
261 else pfmt(f, "[%d=%d]", t->fd0, t->fd1);
262 pfmt(f, " %u %u", c0, c1);