Lines Matching refs:tp
62 struct tbl *tp = NULL;
130 tp = findcom(ap[0], FC_BI | FC_FUNC);
146 if (iosetup(*iowp, tp) < 0) {
152 if (tp && tp->type == CSHELL &&
153 (tp->flag & SPEC_BI))
162 rv = comexec(t, tp, (const char **)ap, flags, xerrok);
479 comexec(struct op *t, struct tbl * volatile tp, const char **ap,
525 while (tp && tp->type == CSHELL) {
528 if (tp->val.f == c_builtin) {
531 tp = NULL;
534 if ((tp = findcom(cp, FC_BI)) == NULL)
536 if (tp->type == CSHELL && (tp->flag & LOW_BI))
539 } else if (tp->val.f == c_exec) {
563 } else if (tp->val.f == c_command) {
599 } else if (tp->flag & LOW_BI) {
605 (tp->flag & LOWER_BI)) {
608 ext_cmd = findcom(tp->name, FC_FUNC | FC_PATH);
611 tp = ext_cmd;
614 } else if (tp->val.f == c_trap) {
619 tp = findcom(ap[0], fcflags & (FC_BI | FC_FUNC));
624 if (!resetspec && (!ap[0] || (tp && (tp->flag & KEEPASN))))
676 } else if (!tp) {
682 tp = findcom(cp, fcflags);
685 switch (tp->type) {
691 l_assign->flags |= (tp->flag & NEXTLOC_BI);
692 rv = call_builtin(tp, (const char **)ap, null, resetspec);
701 if (!(tp->flag & ISSET)) {
704 if (!tp->u.fpath) {
706 rv = (tp->u2.errnov == ENOENT) ? 127 : 126;
709 cstrerror(tp->u2.errnov));
713 if (include(tp->u.fpath, 0, NULL, false) < 0 ||
720 tp = ftp;
724 tp->u2.errnov = rv;
725 cp = tp->u.fpath;
729 "function not defined by", tp->u.fpath);
733 tp = ftp;
741 if (tp->flag & FKSH)
753 if (tp->flag & FKSH) {
762 ((tp->flag & TRACE) ? 1 : 0), false);
763 old_inuse = tp->flag & FINUSE;
764 tp->flag |= FINUSE;
768 execute(tp->val.t, flags & XERROK, NULL);
775 if (tp->flag & FKSH) {
782 tp->flag = (tp->flag & ~FINUSE) | old_inuse;
788 if ((tp->flag & (FDELETE|FINUSE)) == FDELETE) {
789 if (tp->flag & ALLOC) {
790 tp->flag &= ~ALLOC;
791 tfree(tp->val.t, tp->areap);
793 tp->flag = 0;
819 if (!(tp->flag&ISSET)) {
820 if (tp->u2.errnov == ENOENT) {
827 cstrerror(tp->u2.errnov));
835 tp->val.s, KSH_RETURN_ERROR);
841 texec.str = tp->val.s;
871 scriptexec(struct op *tp, const char **ap)
886 *tp->args-- = tp->str;
889 if ((fd = binopen2(tp->str, O_RDONLY | O_MAYEXEC)) >= 0) {
952 *tp->args-- = (char *)cp;
974 errorf("%s: not executable: %d-bit ELF file", tp->str,
989 errorf("%s: not executable: magic %04X", tp->str, m);
992 cp = _getext(tp->str);
996 *tp->args-- = "/c";
998 for (cp = tp->str; *cp; cp++) {
1008 args.ro = tp->args;
1015 errorf(Tf_sD_sD_s, tp->str, sh, cstrerror(errno));
1039 struct tbl *tp = NULL;
1042 tp = ktsearch(&l->funs, name, h);
1043 if (tp)
1046 tp = ktenter(&l->funs, name, h);
1047 tp->flag = DEFINED;
1048 tp->type = CFUNC;
1049 tp->val.t = NULL;
1053 return (tp);
1064 struct tbl *tp;
1070 tp = findfunc(name, nhash, true);
1072 if (tp->flag & ISSET)
1078 if (tp->flag & FINUSE) {
1079 tp->name[0] = '\0';
1081 tp->flag &= ~DEFINED;
1082 tp->flag |= FDELETE;
1087 if (tp->flag & ALLOC) {
1088 tp->flag &= ~(ISSET|ALLOC|FKSH);
1089 tfree(tp->val.t, tp->areap);
1094 ktdelete(tp);
1098 tp->val.t = tcopy(t->left, tp->areap);
1099 tp->flag |= (ISSET|ALLOC);
1101 tp->flag |= FKSH;
1112 struct tbl *tp;
1154 tp = ktenter(&builtins, name, hash(name));
1155 tp->flag = flag;
1156 tp->type = CSHELL;
1157 tp->val.f = func;
1172 struct tbl *tp = NULL, *tbi;
1191 tp = tbi;
1192 if (!tp && (flags & FC_FUNC)) {
1193 tp = findfunc(name, h, false);
1194 if (tp && !(tp->flag & ISSET)) {
1196 tp->u.fpath = NULL;
1197 tp->u2.errnov = ENOENT;
1199 tp->u.fpath = search_path(name, fpath, R_OK,
1200 &tp->u2.errnov);
1203 if (!tp && (flags & FC_NORMBI) && tbi)
1204 tp = tbi;
1205 if (!tp && (flags & FC_PATH) && !(flags & FC_DEFPATH)) {
1206 tp = ktsearch(&taliases, name, h);
1207 if (tp && (tp->flag & ISSET) &&
1208 ksh_access(tp->val.s, X_OK) != 0) {
1209 if (tp->flag & ALLOC) {
1210 tp->flag &= ~ALLOC;
1211 afree(tp->val.s, APERM);
1213 tp->flag &= ~ISSET;
1218 if ((!tp || (tp->type == CTALIAS && !(tp->flag & ISSET))) &&
1220 if (!tp) {
1222 tp = ktenter(&taliases, name, h);
1223 tp->type = CTALIAS;
1225 tp = &temp;
1226 tp->type = CEXEC;
1229 tp->flag = DEFINED;
1233 X_OK, &tp->u2.errnov);
1235 strdupx(tp->val.s, npath.ro, APERM);
1238 tp->flag |= ISSET|ALLOC;
1242 &tp->u2.errnov)) != NULL) {
1249 tp = &temp;
1250 tp->type = CFUNC;
1252 tp->flag = DEFINED;
1253 tp->u.fpath = npath.ro;
1256 return (tp);
1266 struct tbl *tp;
1269 for (ktwalk(&ts, &taliases); (tp = ktnext(&ts)) != NULL; )
1270 if ((tp->flag&ISSET) && (all || !mksh_abspath(tp->val.s))) {
1271 if (tp->flag&ALLOC) {
1272 tp->flag &= ~(ALLOC|ISSET);
1273 afree(tp->val.s, APERM);
1275 tp->flag &= ~ISSET;
1381 call_builtin(struct tbl *tp, const char **wp, const char *where, bool resetspec)
1385 if (!tp)
1388 builtin_spec = tobool(!resetspec && (tp->flag & SPEC_BI));
1392 rv = (*tp->val.f)(wp);
1404 iosetup(struct ioword *iop, struct tbl *tp)
1567 else if (tp && tp->type == CSHELL && tp->val.f == c_exec) {