Lines Matching refs:tp

63 	struct tbl *tp = NULL;
142 tp = findcom(ap[0], FC_BI|FC_FUNC);
158 if (iosetup(*iowp, tp) < 0) {
164 if (tp && tp->type == CSHELL &&
165 (tp->flag & SPEC_BI))
174 rv = comexec(t, tp, (const char **)ap, flags, xerrok);
493 comexec(struct op *t, struct tbl * volatile tp, const char **ap,
536 while (tp && tp->type == CSHELL) {
539 if (tp->val.f == c_builtin) {
542 tp = NULL;
545 if ((tp = findcom(cp, FC_BI)) == NULL)
548 } else if (tp->val.f == c_exec) {
553 } else if (tp->val.f == c_command) {
589 } else if (tp->val.f == c_cat) {
607 } else if (tp->val.f == c_trap) {
612 tp = findcom(ap[0], fcflags & (FC_BI|FC_FUNC));
617 if (keepasn_ok && (!ap[0] || (tp && (tp->flag & KEEPASN))))
623 if (keepasn_ok && tp && tp->type == CFUNC &&
624 !(tp->flag & FKSH)) {
674 } else if (!tp) {
680 tp = findcom(cp, fcflags);
683 switch (tp->type) {
687 rv = call_builtin(tp, (const char **)ap, null);
688 if (!keepasn_ok && tp->val.f == c_shift) {
700 if (!(tp->flag & ISSET)) {
703 if (!tp->u.fpath) {
704 rv = (tp->u2.errnov == ENOENT) ? 127 : 126;
707 cstrerror(tp->u2.errnov));
710 if (include(tp->u.fpath, 0, NULL, false) < 0) {
713 tp->u.fpath, cstrerror(errno));
720 "function not defined by", tp->u.fpath);
724 tp = ftp;
732 if (tp->flag & FKSH)
744 if (tp->flag & FKSH) {
752 ((tp->flag & TRACE) ? 1 : 0), false);
753 old_inuse = tp->flag & FINUSE;
754 tp->flag |= FINUSE;
758 execute(tp->val.t, flags & XERROK, NULL);
764 tp->flag = (tp->flag & ~FINUSE) | old_inuse;
771 if ((tp->flag & (FDELETE|FINUSE)) == FDELETE) {
772 if (tp->flag & ALLOC) {
773 tp->flag &= ~ALLOC;
774 tfree(tp->val.t, tp->areap);
776 tp->flag = 0;
801 if (!(tp->flag&ISSET)) {
802 if (tp->u2.errnov == ENOENT) {
808 cstrerror(tp->u2.errnov));
816 tp->val.s, KSH_RETURN_ERROR);
834 texec.str = tp->val.s;
848 scriptexec(struct op *tp, const char **ap)
865 *tp->args-- = tp->str;
868 if ((fd = open(tp->str, O_RDONLY | O_BINARY)) >= 0) {
919 *tp->args-- = (char *)cp;
924 errorf("%s: not executable: %d-bit ELF file", tp->str,
936 errorf("%s: not executable: magic %04X", tp->str, fd);
939 args.ro = tp->args;
946 errorf("%s: %s: %s", tp->str, sh, cstrerror(errno));
952 struct tbl *tp;
954 tp = ktsearch(&builtins, *wp, hash(*wp));
955 return (call_builtin(tp, wp, "shcomexec"));
966 struct tbl *tp = NULL;
969 tp = ktsearch(&l->funs, name, h);
970 if (tp)
973 tp = ktenter(&l->funs, name, h);
974 tp->flag = DEFINED;
975 tp->type = CFUNC;
976 tp->val.t = NULL;
980 return (tp);
991 struct tbl *tp;
998 if ((tp = ktsearch(&aliases, name, nhash)))
999 ktdelete(tp);
1003 tp = findfunc(name, nhash, true);
1005 mkssert(tp != NULL);
1007 if (tp->flag & ISSET)
1013 if (tp->flag & FINUSE) {
1014 tp->name[0] = '\0';
1016 tp->flag &= ~DEFINED;
1017 tp->flag |= FDELETE;
1022 if (tp->flag & ALLOC) {
1023 tp->flag &= ~(ISSET|ALLOC);
1024 tfree(tp->val.t, tp->areap);
1029 ktdelete(tp);
1033 tp->val.t = tcopy(t->left, tp->areap);
1034 tp->flag |= (ISSET|ALLOC);
1036 tp->flag |= FKSH;
1047 struct tbl *tp;
1063 tp = ktenter(&builtins, name, hash(name));
1064 tp->flag = flag;
1065 tp->type = CSHELL;
1066 tp->val.f = func;
1080 struct tbl *tp = NULL, *tbi;
1099 tp = tbi;
1100 if (!tp && (flags & FC_FUNC)) {
1101 tp = findfunc(name, h, false);
1102 if (tp && !(tp->flag & ISSET)) {
1104 tp->u.fpath = NULL;
1105 tp->u2.errnov = ENOENT;
1107 tp->u.fpath = search_path(name, fpath, R_OK,
1108 &tp->u2.errnov);
1111 if (!tp && (flags & FC_NORMBI) && tbi)
1112 tp = tbi;
1113 if (!tp && (flags & FC_PATH) && !(flags & FC_DEFPATH)) {
1114 tp = ktsearch(&taliases, name, h);
1115 if (tp && (tp->flag & ISSET) &&
1116 ksh_access(tp->val.s, X_OK) != 0) {
1117 if (tp->flag & ALLOC) {
1118 tp->flag &= ~ALLOC;
1119 afree(tp->val.s, APERM);
1121 tp->flag &= ~ISSET;
1126 if ((!tp || (tp->type == CTALIAS && !(tp->flag&ISSET))) &&
1128 if (!tp) {
1130 tp = ktenter(&taliases, name, h);
1131 tp->type = CTALIAS;
1133 tp = &temp;
1134 tp->type = CEXEC;
1137 tp->flag = DEFINED;
1141 X_OK, &tp->u2.errnov);
1143 strdupx(tp->val.s, npath.ro, APERM);
1146 tp->flag |= ISSET|ALLOC;
1150 &tp->u2.errnov)) != NULL) {
1157 tp = &temp;
1158 tp->type = CFUNC;
1160 tp->flag = DEFINED;
1161 tp->u.fpath = npath.ro;
1164 return (tp);
1174 struct tbl *tp;
1177 for (ktwalk(&ts, &taliases); (tp = ktnext(&ts)) != NULL; )
1178 if ((tp->flag&ISSET) && (all || tp->val.s[0] != '/')) {
1179 if (tp->flag&ALLOC) {
1180 tp->flag &= ~(ALLOC|ISSET);
1181 afree(tp->val.s, APERM);
1183 tp->flag &= ~ISSET;
1268 call_builtin(struct tbl *tp, const char **wp, const char *where)
1272 if (!tp)
1275 builtin_flag = tp->flag;
1279 rv = (*tp->val.f)(wp);
1291 iosetup(struct ioword *iop, struct tbl *tp)
1428 else if (tp && tp->type == CSHELL && tp->val.f == c_exec) {