Lines Matching refs:pl
621 int run_pipeline(struct sh_pipeline **pl, int *rd) in run_pipeline() argument
628 if (!(pp = run_command((*pl)->arg, &rd))) rc = 0; in run_pipeline()
636 if ((*pl)->next && !(*pl)->next->type) *pl = (*pl)->next; in run_pipeline()
657 struct sh_pipeline *pl = pipeline; in free_pipeline() local
660 if (pl) for (j=0; j<=pl->count; j++) { in free_pipeline()
661 for (i = 0; i<=pl->arg->c; i++) free(pl->arg[j].v[i]); in free_pipeline()
662 free(pl->arg[j].v); in free_pipeline()
664 free(pl); in free_pipeline()
668 struct sh_pipeline *block_end(struct sh_pipeline *pl) in block_end() argument
672 while (pl) { in block_end()
673 if (pl->type == 1 || pl->type == 'f') i++; in block_end()
674 else if (pl->type == 3) if (--i<1) break; in block_end()
675 pl = pl->next; in block_end()
689 struct sh_pipeline *add_function(char *name, struct sh_pipeline *pl) in add_function() argument
693 return block_end(pl->next); in add_function()
701 struct sh_pipeline *pl = sp->pipeline ? sp->pipeline->prev : 0; in parse_line() local
706 if (pl) { in parse_line()
707 arg = pl->arg; in parse_line()
716 } else if (pl->count != pl->here) { in parse_line()
717 arg += 1+pl->here; in parse_line()
727 pl->here++; in parse_line()
732 } else pl = 0; in parse_line()
740 if (pl && pl->count == -1) { in parse_line()
741 pl->count = 0; in parse_line()
742 arg = pl->arg; in parse_line()
753 pl = xrealloc(pl, sizeof(*pl) + ++pl->count*sizeof(struct sh_arg)); in parse_line()
754 dlist_add_nomalloc((void *)&sp->pipeline, (void *)pl); in parse_line()
757 arg[pl->count].v = xzalloc(2*sizeof(void *)); in parse_line()
758 *arg[pl->count].v = arg->v[++i]; in parse_line()
759 arg[pl->count].c = -(s[2] == '<'); // note <<< as c = -1 in parse_line()
761 pl = 0; in parse_line()
778 if (!pl) { in parse_line()
779 pl = xzalloc(sizeof(struct sh_pipeline)); in parse_line()
780 arg = pl->arg; in parse_line()
781 dlist_add_nomalloc((void *)&sp->pipeline, (void *)pl); in parse_line()
799 if (end == start || (arg->c && *start == ')' && pl->type!='f')) { in parse_line()
802 if (pl->type == 'f' && arg->c<3) { in parse_line()
818 pl->count = -1; in parse_line()
839 pl->count = -1; in parse_line()
845 if (arg->c>1 && !strcmp(s, "(")) pl->type = 'f'; in parse_line()
846 if (pl->type=='f') { in parse_line()
852 pl->count = -1; in parse_line()
866 pl->count = -1; in parse_line()
889 if (!pl->prev->type) goto flush; in parse_line()
890 if (!strncmp(pl->prev->arg->v[1], "((", 2)) goto flush; in parse_line()
902 if (!pl->type) pl->type = 1; in parse_line()
924 pl->type = 1; in parse_line()
938 pl->type = anystr(s, (char *[]){"fi", "done", "esac", "}", "]]", ")", 0}) in parse_line()
963 if (!pl->type) pl->type = 2; in parse_line()
966 pl->count = -1; in parse_line()
971 if (!pl->type && anystr(s, (char *[]){"then", "do", "esac", "}", "]]", ")", in parse_line()
977 pl = sp->pipeline->prev; in parse_line()
978 while (pl->count<pl->here && pl->arg[pl->count].c<0) in parse_line()
979 pl->arg[pl->count++].c = 0; in parse_line()
983 if (sp->pipeline && pl->count != pl->here) return 1; in parse_line()
999 struct sh_pipeline *pl; in dump_state() local
1013 for (pl = sp->pipeline; pl ; pl = (pl->next == sp->pipeline) ? 0 : pl->next) { in dump_state()
1014 for (i = 0; i<pl->arg->c; i++) in dump_state()
1015 printf("arg[%d][%ld]=%s\n", q, i, pl->arg->v[i]); in dump_state()
1016 printf("type=%d term[%d]=%s\n", pl->type, q++, pl->arg->v[pl->arg->c]); in dump_state()
1031 struct sh_pipeline *pl = sp->pipeline, *end; in run_function() local
1044 while (pl) { in run_function()
1045 char *s = *pl->arg->v, *ss = pl->arg->v[1]; in run_function()
1048 if (!pl->type) { in run_function()
1056 if (!blk || pl->arg->c>2 || ss[strspn(ss, "0123456789")]) { in run_function()
1064 pl = blk->start; in run_function()
1067 pl = blk->end; in run_function()
1071 pl = pl->next; in run_function()
1078 if (!blk) toys.exitval = run_pipeline(&pl, 0); in run_function()
1079 else if (blk->run) toys.exitval = run_pipeline(&pl, blk->redir); in run_function()
1080 else while (pl->next && !pl->next->type) pl = pl->next; in run_function()
1083 } else if (pl->type == 1) { in run_function()
1086 if (!blk || blk->start != pl) { in run_function()
1089 end = block_end(pl->next); in run_function()
1091 pl = end; in run_function()
1092 if (pl) pl = pl->next; in run_function()
1100 blk->start = pl; in run_function()
1119 if (!pl->next->type) { in run_function()
1120 for (i = 1; i<pl->next->arg->c; i++) in run_function()
1121 expand_arg(&blk->farg, pl->next->arg->v[i], 0, &blk->fdelete); in run_function()
1124 pl = pl->next; in run_function()
1137 } else if (pl->type == 2) { in run_function()
1148 pl = block_end(pl); in run_function()
1157 } else if (pl->type == 3) { in run_function()
1161 pl = blk->start; in run_function()
1171 } else if (pl->type == 'f') pl = add_function(s, pl); in run_function()
1173 pl = pl->next; in run_function()