static void phist(struct Hist *hp, int hflg) { if (hflg == 0) (void)fprintf(cshout, "%6d\t", hp->Hnum); prlex(cshout, &hp->Hlex); }
static int tellmewhat(struct wordent *lexp, Char *str) { struct biltins *bptr; struct wordent *sp; Char *cmd, *s0, *s1, *s2; int i; int aliased, found; Char qc; aliased = 0; sp = lexp->next; if (adrof1(sp->word, &aliases)) { alias(lexp); sp = lexp->next; aliased = 1; } s0 = sp->word; /* to get the memory freeing right... */ /* handle quoted alias hack */ if ((*(sp->word) & (QUOTE | TRIM)) == QUOTE) (sp->word)++; /* do quoting, if it hasn't been done */ s1 = s2 = sp->word; while (*s2) switch (*s2) { case '\'': case '"': qc = *s2++; while (*s2 && *s2 != qc) *s1++ = (Char)(*s2++ | QUOTE); if (*s2) s2++; break; case '\\': if (*++s2) *s1++ = (Char)(*s2++ | QUOTE); break; default: *s1++ = *s2++; } *s1 = '\0'; for (bptr = bfunc; bptr < &bfunc[nbfunc]; bptr++) { if (eq(sp->word, str2short(bptr->bname))) { if (str == NULL) { if (aliased) prlex(cshout, lexp); (void)fprintf(cshout, "%s: shell built-in command.\n", vis_str(sp->word)); } else (void)Strcpy(str, sp->word); sp->word = s0; /* we save and then restore this */ return 1; } } sp->word = cmd = globone(sp->word, G_IGNORE); if ((i = iscommand(sp->word)) != 0) { Char **pv; struct varent *v; int slash = any(short2str(sp->word), '/'); v = adrof(STRpath); if (v == 0 || v->vec[0] == 0 || slash) pv = justabs; else pv = v->vec; while (--i) pv++; if (pv[0][0] == 0 || eq(pv[0], STRdot)) { if (!slash) { sp->word = Strspl(STRdotsl, sp->word); prlex(cshout, lexp); free(sp->word); } else prlex(cshout, lexp); } else { s1 = Strspl(*pv, STRslash); sp->word = Strspl(s1, sp->word); free(s1); if (str == NULL) prlex(cshout, lexp); else (void)Strcpy(str, sp->word); free(sp->word); } found = 1; } else { if (str == NULL) { if (aliased) prlex(cshout, lexp); (void)fprintf(csherr, "%s: Command not found.\n", vis_str(sp->word)); } else (void)Strcpy(str, sp->word); found = 0; } sp->word = s0; /* we save and then restore this */ free(cmd); return found; }