- l = 0;
- for (p = p1; p != p2; p = p->next)
- switch (p->word[0]) {
-
- case '(':
- if (specp)
- n++;
- l++;
- continue;
-
- case ')':
- if (specp)
- n++;
- l--;
- continue;
-
- case '>':
- case '<':
- if (l != 0) {
- if (specp)
- n++;
- continue;
- }
- if (p->next == p2)
- continue;
- if (index(RELPAR, p->next->word[0]))
- continue;
- n--;
- continue;
-
- default:
- if (!specp && l != 0)
- continue;
- n++;
- continue;
- }
- if (n < 0)
- n = 0;
- t = (struct command *) calloc(1, sizeof (*t));
- av = (char **) calloc((unsigned) (n + 1), sizeof (char **));
- t->t_dcom = av;
- n = 0;
- if (p2->word[0] == ')')
- t->t_dflg = FPAR;
- lp = 0;
- rp = 0;
- l = 0;
- for (p = p1; p != p2; p = p->next) {
- c = p->word[0];
- switch (c) {
-
- case '(':
- if (l == 0) {
- if (lp != 0 && !specp)
- seterr("Badly placed (");
- lp = p->next;
- }
- l++;
- goto savep;
-
- case ')':
- l--;
- if (l == 0)
- rp = p;
- goto savep;
-
- case '>':
- if (l != 0)
- goto savep;
- if (p->word[1] == '>')
- t->t_dflg |= FCAT;
- if (p->next != p2 && eq(p->next->word, "&")) {
- t->t_dflg |= FDIAG, p = p->next;
- if (flags & (POUT|PDIAG))
- goto badout;
- }
- if (p->next != p2 && eq(p->next->word, "!"))
- t->t_dflg |= FANY, p = p->next;
- if (p->next == p2) {
-missfile:
- seterr("Missing name for redirect");
- continue;
- }
- p = p->next;
- if (index(RELPAR, p->word[0]))
- goto missfile;
- if ((flags & POUT) && (flags & PDIAG) == 0 || t->t_drit)
-badout:
- seterr("Ambiguous output redirect");
- else
- t->t_drit = savestr(p->word);
- continue;
-
- case '<':
- if (l != 0)
- goto savep;
- if (p->word[1] == '<')
- t->t_dflg |= FHERE;
- if (p->next == p2)
- goto missfile;
- p = p->next;
- if (index(RELPAR, p->word[0]))
- goto missfile;
- if ((flags & PHERE) && (t->t_dflg & FHERE))
- seterr("Can't << within ()'s");
- else if ((flags & PIN) || t->t_dlef)
- seterr("Ambiguous input redirect");
- else
- t->t_dlef = savestr(p->word);
- continue;
-
-savep:
- if (!specp)
- continue;
- default:
- if (l != 0 && !specp)
- continue;
- if (err == 0)
- av[n] = savestr(p->word);
- n++;
- continue;
+ t = (struct command *) xcalloc(1, sizeof(*t));
+ av = (Char **) xcalloc((size_t) (n + 1), sizeof(Char **));
+ t->t_dcom = av;
+ n = 0;
+ if (p2->word[0] == ')')
+ t->t_dflg = F_NOFORK;
+ lp = 0;
+ rp = 0;
+ l = 0;
+ for (p = p1; p != p2; p = p->next) {
+ c = p->word[0];
+ switch (c) {
+
+ case '(':
+ if (l == 0) {
+ if (lp != 0 && !specp)
+ seterror(ERR_BADPLP);
+ lp = p->next;
+ }
+ l++;
+ goto savep;
+
+ case ')':
+ l--;
+ if (l == 0)
+ rp = p;
+ goto savep;
+
+ case '>':
+ if (l != 0)
+ goto savep;
+ if (p->word[1] == '>')
+ t->t_dflg |= F_APPEND;
+ if (p->next != p2 && eq(p->next->word, STRand)) {
+ t->t_dflg |= F_STDERR, p = p->next;
+ if (flags & (POUT | PDIAG)) {
+ seterror(ERR_OUTRED);
+ continue;