Char
Char STRnice[] = { 'n', 'i', 'c', 'e', '\0' };
Char STRnoambiguous[] = { 'n', 'o', 'a', 'm', 'b', 'i', 'g', 'u', 'o', 'u',
Char STRnobeep[] = { 'n', 'o', 'b', 'e', 'e', 'p', '\0' };
Char STRnoclobber[] = { 'n', 'o', 'c', 'l', 'o', 'b', 'b', 'e', 'r', '\0' };
Char STRnoglob[] = { 'n', 'o', 'g', 'l', 'o', 'b', '\0' };
Char STRnohup[] = { 'n', 'o', 'h', 'u', 'p', '\0' };
Char STRnonomatch[] = { 'n', 'o', 'n', 'o', 'm', 'a', 't', 'c', 'h', '\0' };
Char STRnormal[] = { 'n', 'o', 'r', 'm', 'a', 'l', '\0' };
Char STRnotify[] = { 'n', 'o', 't', 'i', 'f', 'y', '\0' };
Char STRor[] = { '|', '\0' };
Char STRor2[] = { '|', '|', '\0' };
Char STRpath[] = { 'p', 'a', 't', 'h', '\0' };
Char STRprintexitvalue[] = { 'p', 'r', 'i', 'n', 't', 'e', 'x', 'i', 't', 'v',
Char STRprompt[] = { 'p', 'r', 'o', 'm', 'p', 't', '\0' };
Char STRprompt2[] = { 'p', 'r', 'o', 'm', 'p', 't', '2', '\0' };
Char STRpromptroot[] = { '%', 'm', '#', ' ', '\0' };
Char STRpromptuser[] = { '%', 'm', '%', ' ', '\0' };
Char STRpushdsilent[] = { 'p', 'u', 's', 'h', 'd', 's', 'i', 'l', 'e', 'n',
Char STRret[] = { '\n', '\0' };
Char STRsavehist[] = { 's', 'a', 'v', 'e', 'h', 'i', 's', 't', '\0' };
Char STRsemisp[] = { ';', ' ', '\0' };
Char STRshell[] = { 's', 'h', 'e', 'l', 'l', '\0' };
Char STRslash[] = { '/', '\0' };
Char STRsldotcshrc[] = { '/', '.', 'c', 's', 'h', 'r', 'c', '\0' };
Char STRsldotlogin[] = { '/', '.', 'l', 'o', 'g', 'i', 'n', '\0' };
Char STRsldthist[] = { '/', '.', 'h', 'i', 's', 't', 'o', 'r', 'y', '\0' };
Char STRsldtlogout[] = { '/', '.', 'l', 'o', 'g', 'o', 'u', 't', '\0' };
Char STRsource[] = { 's', 'o', 'u', 'r', 'c', 'e', '\0' };
Char STRsp3dots[] = { ' ', '.', '.', '.', '\0' };
Char STRspLarrow2sp[] = { ' ', '<', '<', ' ', '\0' };
Char STRspLarrowsp[] = { ' ', '<', ' ', '\0' };
Char STRspRarrow[] = { ' ', '>', '\0' };
Char STRspRarrow2[] = { ' ', '>', '>', '\0' };
Char STRRparen[] = { ')', '\0' };
Char STRspace[] = { ' ', '\0' };
Char STRspand2sp[] = { ' ', '&', '&', ' ', '\0' };
Char STRspor2sp[] = { ' ', '|', '|', ' ', '\0' };
Char STRsporsp[] = { ' ', '|', ' ', '\0' };
Char STRstar[] = { '*', '\0' };
Char STRstatus[] = { 's', 't', 'a', 't', 'u', 's', '\0' };
Char STRterm[] = { 't', 'e', 'r', 'm', '\0' };
Char STRthen[] = { 't', 'h', 'e', 'n', '\0' };
Char STRtilde[] = { '~', '\0' };
Char STRtime[] = { 't', 'i', 'm', 'e', '\0' };
Char STRtmpsh[] = { '/', 't', 'm', 'p', '/', 's', 'h', '\0' };
Char STRunalias[] = { 'u', 'n', 'a', 'l', 'i', 'a', 's', '\0' };
Char STRuser[] = { 'u', 's', 'e', 'r', '\0' };
Char STRverbose[] = { 'v', 'e', 'r', 'b', 'o', 's', 'e', '\0' };
Char STRwordchars[] = { 'w', 'o', 'r', 'd', 'c', 'h', 'a', 'r', 's', '\0' };
Char STR0[] = { '0', '\0' };
Char STR1[] = { '1', '\0' };
Char STRHOME[] = { 'H', 'O', 'M', 'E', '\0' };
Char STRLOGNAME[] = { 'L', 'O', 'G', 'N', 'A', 'M', 'E', '\0' };
Char STRLbrace[] = { '{', '\0' };
Char STRLparen[] = { '(', '\0' };
Char STRLparensp[] = { '(', ' ', '\0' };
Char STRNULL[] = { '\0' };
Char STRPATH[] = { 'P', 'A', 'T', 'H', '\0' };
Char STRPWD[] = { 'P', 'W', 'D', '\0' };
Char STRQNULL[] = { '\0' | QUOTE, '\0' };
Char STRRbrace[] = { '}', '\0' };
Char STRspRparen[] = { ' ', ')', '\0' };
Char STRTERM[] = { 'T', 'E', 'R', 'M', '\0' };
Char STRUSER[] = { 'U', 'S', 'E', 'R', '\0' };
Char STRalias[] = { 'a', 'l', 'i', 'a', 's', '\0' };
Char STRand[] = { '&', '\0' };
Char STRand2[] = { '&', '&', '\0' };
Char STRaout[] = { 'a', '.', 'o', 'u', 't', '\0' };
Char STRargv[] = { 'a', 'r', 'g', 'v', '\0' };
Char STRbang[] = { '!', '\0' };
Char STRcaret[] = { '^', '\0' };
Char STRcdpath[] = { 'c', 'd', 'p', 'a', 't', 'h', '\0' };
Char STRcent2[] = { '%', '%', '\0' };
Char STRcenthash[] = { '%', '#', '\0' };
Char STRcentplus[] = { '%', '+', '\0' };
Char STRcentminus[] = { '%', '-', '\0' };
Char STRchase_symlinks[] = { 'c', 'h', 'a', 's', 'e', '_', 's', 'y', 'm', 'l',
Char STRchild[] = { 'c', 'h', 'i', 'l', 'd', '\0' };
Char STRcolon[] = { ':', '\0' };
Char STRcwd[] = { 'c', 'w', 'd', '\0' };
Char STRdefault[] = { 'd', 'e', 'f', 'a', 'u', 'l', 't', '\0' };
Char STRdot[] = { '.', '\0' };
Char STRdotdotsl[] = { '.', '.', '/', '\0' };
Char STRdotsl[] = { '.', '/', '\0' };
Char STRecho[] = { 'e', 'c', 'h', 'o', '\0' };
Char STRequal[] = { '=', '\0' };
Char STRfakecom[] = { '{', ' ', '.', '.', '.', ' ', '}', '\0' };
Char STRfakecom1[] = { '`', ' ', '.', '.', '.', ' ', '`', '\0' };
Char STRfignore[] = { 'f', 'i', 'g', 'n', 'o', 'r', 'e', '\0' };
Char STRfilec[] = { 'f', 'i', 'l', 'e', 'c', '\0' };
Char STRhistchars[] = { 'h', 'i', 's', 't', 'c', 'h', 'a', 'r', 's', '\0' };
Char STRtildothist[] = { '~', '/', '.', 'h', 'i', 's', 't', 'o', 'r',
Char STRhistfile[] = { 'h', 'i', 's', 't', 'f', 'i', 'l', 'e', '\0' };
Char STRhistory[] = { 'h', 'i', 's', 't', 'o', 'r', 'y', '\0' };
Char STRhome[] = { 'h', 'o', 'm', 'e', '\0' };
Char STRignore_symlinks[] = { 'i', 'g', 'n', 'o', 'r', 'e', '_', 's', 'y', 'm',
Char STRignoreeof[] = { 'i', 'g', 'n', 'o', 'r', 'e', 'e', 'o', 'f', '\0' };
Char STRjobs[] = { 'j', 'o', 'b', 's', '\0' };
Char STRlistjobs[] = { 'l', 'i', 's', 't', 'j', 'o', 'b', 's', '\0' };
Char STRlogout[] = { 'l', 'o', 'g', 'o', 'u', 't', '\0' };
Char STRlong[] = { 'l', 'o', 'n', 'g', '\0' };
Char STRmail[] = { 'm', 'a', 'i', 'l', '\0' };
Char STRmh[] = { '-', 'h', '\0' };
Char STRminus[] = { '-', '\0' };
Char STRml[] = { '-', 'l', '\0' };
Char STRmn[] = { '-', 'n', '\0' };
Char STRmquestion[] = { '?' | QUOTE, ' ', '\0' };
Char *gointr;
Char *lap;
dosource(Char **v, struct command *t)
Char **alvec;
Char *f;
Char buf[BUFSIZ];
(void) Strlcpy(buf, *v, sizeof buf/sizeof(Char));
Char *pargs;
Char **vp;
Char *pargcp;
Char HIST;
gethdir(Char *home, int len)
Char *h;
Char HISTSUB;
Char *Vsav;
Char *Vdp;
Char *Vexpath;
Char **evalvec;
Char *evalp;
Char *word_chars;
Char *STR_SHELLPATH;
static Char **
Char **blk, **blkp;
blkp = blk = xreallocarray(NULL, 10, sizeof(Char *));
Char *STR_BSHELL;
Char *STR_WORD_CHARS;
Char *cp;
Char **STR_environ;
Char *dumphist[] = {STRhistory, STRmh, 0, 0};
Char *loadhist[] = {STRsource, STRmh, STRtildothist, 0};
static int srccat(Char *, Char *);
static Char **defaultpath(void);
Char *cp;
importpath(Char *cp)
Char *dp;
Char **pv;
srccat(Char *cp, Char *dp)
Char *ep = Strspl(cp, dp);
Char *ogointr = gointr, *oarginp = arginp;
Char *oevalp = evalp, **oevalvec = evalvec;
Char buf[BUFSIZ], hbuf[BUFSIZ], *hfile;
(void) Strlcpy(hbuf, shist->vec[0], sizeof hbuf/sizeof(Char));
(void) Strlcpy(hbuf, shist->vec[0], sizeof hbuf/sizeof(Char));
Strlcpy(buf, value(STRhome), sizeof buf/sizeof(Char));
(void) Strlcat(buf, STRsldthist, sizeof buf/sizeof(Char));
Char *s;
Char *arginp;
Char *jobargv[2] = {STRjobs, 0};
Char *ffile;
Char *doldol;
extern Char *arginp; /* Argument input for sh -c and internal `xx` */
extern Char *ffile; /* Name of shell file for $0 */
extern Char *doldol; /* Character pid for $$ */
extern Char *gointr; /* Label for an onintr transfer */
Char **Bfbuf; /* The array of buffer blocks */
Char* _c_seek;
Char **a_seek;
Char *word;
extern Char *lap;
Char *T_dlef; /* Input redirect word */
Char *T_drit; /* Output redirect word */
Char **t_dcom; /* Command/argument vector */
void (*bfunct)(Char **, struct command *);
Char **w_fe, **w_fe0; /* Current/initial wordlist for fe */
Char *w_fename; /* Name for fe */
Char **vec; /* Array of words which is the value */
Char *v_name; /* Name of variable/alias */
struct varent *adrof1(Char *, struct varent *);
extern Char **alvec, *alvecp; /* The (remnants of) alias vector */
extern Char **gargv; /* Pointer to the (stack) arglist */
extern Char **pargv; /* Pointer to the argv list space */
extern Char *pargs; /* Pointer to start current word */
extern Char *pargcp; /* Current index into pargs */
extern Char HIST; /* history invocation character */
extern Char HISTSUB; /* auto-substitute character */
extern Char *Vsav;
extern Char *Vdp;
extern Char *Vexpath;
extern Char **evalvec;
extern Char *evalp;
extern Char *word_chars;
extern Char *STR_SHELLPATH;
extern Char *STR_BSHELL;
extern Char *STR_WORD_CHARS;
extern Char **STR_environ;
dset(Char *dp)
Char **vec = xreallocarray(NULL, 2, sizeof(*vec));
skipargs(Char ***v, char *str)
Char **n = *v, *s;
dodirs(Char **v, struct command *t)
Char *s, *hp = value(STRhome);
dtildepr(Char *home, Char *dir)
Char *
dnormalize(Char *cp)
Char *dp, *cwd;
cwd = xreallocarray(NULL, len, sizeof(Char));
dochngd(Char **v, struct command *t)
Char *cp;
static Char *
dgoto(Char *cp)
Char *dp;
Char *p, *q;
dp = xreallocarray(NULL, (cwdlen + (p - cp) + 1), sizeof(Char));
static Char *
dfollow(Char *cp)
Char *dp;
Char **cdp;
Char *p;
Char buf[PATH_MAX];
dopushd(Char **v, struct command *t)
*dfind(Char *);
static Char *dfollow(Char *);
Char *ccp;
static Char *dgoto(Char *);
dfind(Char *cp)
Char *ep;
static void dset(Char *);
dopopd(Char **v, struct command *t)
Char *
dcanon(Char *cp, Char *p)
Char *sp;
Char *p1, *p2; /* general purpose */
Char link[PATH_MAX];
Char *newcp;
Char tmpdir[PATH_MAX];
(void) Strlcpy(tmpdir, p1, sizeof tmpdir/sizeof(Char));
(void) Strlcat(tmpdir, STRslash, sizeof tmpdir/sizeof(Char));
(void) Strlcat(tmpdir, cp, sizeof tmpdir/sizeof(Char));
dinit(Char *hp)
(void) Strlcpy(link, str2short(tlink), sizeof link/sizeof(Char));
Char *cp = NULL;
(sp - cp) + cc + (p1 - p), sizeof(Char));
sizeof(Char));
(void) Strlcpy(link, str2short(tlink), sizeof link/sizeof(Char));
(sp - cp) + cc + (p1 - p), sizeof(Char));
p1 = newcp = xreallocarray(NULL, cc + (p1 - p), sizeof(Char));
static Char *home_ptr = NULL;
Strlcpy(link, cp, sizeof link/sizeof(Char));
sp = (Char *) - 1;
if (*p2 && sp == (Char *) -1) {
Char *di_name; /* actual name */
Char *
Dfix1(Char *cp)
Char *Dv[2];
Dfix2(Char **v)
static Char *
Dpack(Char *wbuf, Char *wp)
Char wbuf[BUFSIZ];
Char *wp = wbuf;
static Char *nulvec[] = {0};
dolerror(Char *s)
Char *np;
Char name[4 * MAXVARLEN + 1];
Char wbuf[BUFSIZ];
static Char *dolbang = NULL;
(void) Strlcpy(name, STRargv, sizeof name/sizeof(Char));
if (np >= &name[sizeof(name) / sizeof(Char) - 2])
static Char *Dcp, **Dvp; /* Input vector for Dreadc */
Char *cp = putn(upb - lwb + 1);
setDolp(Char *cp)
Char *dp;
Char *lhsub, *rhsub, *np;
static Char *dolp; /* Remaining chars from this word */
static Char **dolnxt; /* Further words */
np = xreallocarray(NULL, len, sizeof(Char));
static Char dolmod[MAXMOD]; /* : modifier character */
static void Dfix2(Char **);
static Char *Dpack(Char *, Char *);
static void dolerror(Char *);
heredoc(Char *term)
Char *Dv[2];
Char obuf[BUFSIZ], lbuf[BUFSIZ], mbuf[BUFSIZ];
Char *lbp, *obp, *mbp;
Char **vp;
static void setDolp(Char *);
Char **pp;
Char *p;
doexec(Char **v, struct command *t)
Char *dp, **pv, **av, *sav;
Char *blk[2];
texec(Char *sf, Char **st)
Char **vp;
Char *lastsh[2];
Char *st0, **ost;
blkfree((Char **) t);
blkfree((Char **) t);
execash(Char **t, struct command *kp)
xechoit(Char **t)
dohash(Char **v, struct command *t)
Char **pv;
dounhash(Char **v, struct command *t)
hashstat(Char **v, struct command *t)
hashname(Char *cp)
iscommand(Char *name)
Char **pv;
Char *sav;
executable(Char *dir, Char *name, bool dir_ok)
Char path[PATH_MAX], *dp, *sp;
dowhich(Char **v, struct command *c)
tellmewhat(struct wordent *lexp, Char *str, int len)
Char *s0, *s1, *s2, *cmd;
Char qc;
static Char *expath; /* Path for exerr */
(void) Strlcpy(str, sp->word, len/sizeof(Char));
Char **pv;
(void) Strlcpy(str, sp->word, len/sizeof(Char));
(void) Strlcpy(str, sp->word, len/sizeof(Char));
static Char *justabs[] = {STRNULL, 0};
static void texec(Char *, Char **);
static int hashname(Char *);
static int tellmewhat(struct wordent *, Char *, int len);
static int executable(Char *, Char *, bool);
static int iscommand(Char *);
exp2_(Char ***vp, bool ignore)
exp2a(Char ***vp, bool ignore)
exp2b(Char ***vp, bool ignore)
exp2c(Char ***vp, bool ignore)
Char *p1 = exp3(vp, ignore);
Char *p2;
static Char *
exp3(Char ***vp, bool ignore)
Char *p1, *p2;
static Char *
exp3a(Char ***vp, bool ignore)
Char *p1, *p2, *op;
static Char *
exp4(Char ***vp, bool ignore)
Char *p1, *p2;
Char *op = *(*vp)++;
static Char *
exp5(Char ***vp, bool ignore)
Char *p1, *p2;
Char *op = *(*vp)++;
static Char *
exp6(Char ***vp, bool ignore)
Char *cp, *dp, *ep;
Char **v;
Char *fakecom[2];
evalav(Char **v)
isa(Char *cp, int what)
egetn(Char *cp)
static int exp1(Char ***, bool);
static int exp2_(Char ***, bool);
static int exp2a(Char ***, bool);
static int exp2b(Char ***, bool);
static int exp2c(Char ***, bool);
static Char * exp3(Char ***, bool);
static Char * exp3a(Char ***, bool);
static Char * exp4(Char ***, bool);
static Char * exp5(Char ***, bool);
static Char * exp6(Char ***, bool);
static void evalav(Char **);
static int isa(Char *, int);
static int egetn(Char *);
expr(Char ***vp)
exp0(Char ***vp, bool ignore)
exp1(Char ***vp, bool ignore)
int tenex(Char *, int);
void Setenv(Char *, Char *);
void doalias(Char **, struct command *);
void dobreak(Char **, struct command *);
void docontin(Char **, struct command *);
void doecho(Char **, struct command *);
void doelse(Char **, struct command *);
void doend(Char **, struct command *);
void doeval(Char **, struct command *);
void doexit(Char **, struct command *);
void doforeach(Char **, struct command *);
void doglob(Char **, struct command *);
void dogoto(Char **, struct command *);
void doif(Char **, struct command *);
void dolimit(Char **, struct command *);
void dologin(Char **, struct command *);
void dologout(Char **, struct command *);
void donohup(Char **, struct command *);
void doonintr(Char **, struct command *);
void dorepeat(Char **, struct command *);
void dosetenv(Char **, struct command *);
void dosuspend(Char **, struct command *);
void doswbrk(Char **, struct command *);
void doswitch(Char **, struct command *);
void doumask(Char **, struct command *);
void dounlimit(Char **, struct command *);
void dounsetenv(Char **, struct command *);
void dowhile(Char **, struct command *);
void dozip(Char **, struct command *);
void gotolab(Char *);
int srchx(Char *);
void unalias(Char **, struct command *);
Char **dobackp(Char *, bool);
void Gcat(Char *, Char *);
Char *globone(Char *, int);
int Gmatch(Char *, Char *);
Char **globall(Char **);
void rscan(Char **, void (*)(int));
void tglob(Char **);
void trim(Char **);
void dohist(Char **, struct command *);
void addla(Char *);
Char *domod(Char *, int);
Char **blkcat(Char **, Char **);
Char **blkcpy(Char **, Char **);
Char **blkend(Char **);
void blkfree(Char **);
int blklen(Char **);
void blkpr(FILE *, Char **);
Char **blkspl(Char **, Char **);
Char **copyblk(Char **);
Char lastchr(Char *);
void lshift(Char **, int);
int number(Char *);
int prefix(Char *, Char *);
Char **saveblk(Char **);
Char *strip(Char *);
Char *quote(Char *);
void udvar(Char *);
void dobg(Char **, struct command *);
void dobg1(Char **, struct command *);
void dofg(Char **, struct command *);
void dofg1(Char **, struct command *);
void dojobs(Char **, struct command *);
void dokill(Char **, struct command *);
void donotify(Char **, struct command *);
void dostop(Char **, struct command *);
void dowait(Char **, struct command *);
pfind(Char *);
*adrof1(Char *, struct varent *);
void doset(Char **, struct command *);
void dolet(Char **, struct command *);
Char *putn(int);
int getn(Char *);
Char *value1(Char *, struct varent *);
void set(Char *, Char *);
void set1(Char *, Char **, struct varent *);
void setq(Char *, Char **, struct varent *);
void unset(Char **, struct command *);
void unset1(Char *[], struct varent *);
void unsetv(Char *);
void setNS(Char *);
void shift(Char **, struct command *);
void donice(Char **, struct command *);
void dotime(Char **, struct command *);
size_t Strlcpy(Char *, const Char *, size_t);
size_t Strlcat(Char *, const Char *, size_t);
Char *Strchr(Char *, int);
Char *Strrchr(Char *, int);
Char *Strspl(Char *, Char *);
size_t Strlen(Char *);
int Strcmp(Char *, Char *);
int Strncmp(Char *, Char *, size_t);
Char *Strsave(Char *);
Char *Strend(Char *);
Char *Strstr(Char *, Char *);
Char *str2short(char *);
Char **blk2short(char **);
char *short2str(Char *);
char **short2blk(Char **);
char *short2qstr(Char *);
char *vis_str(Char *);
int gethdir(Char *, int);
void dosource(Char **, struct command *);
void importpath(Char *);
void dinit(Char *);
void dodirs(Char **, struct command *);
Char *dcanon(Char *, Char *);
void dtildepr(Char *, Char *);
void dochngd(Char **, struct command *);
Char *dnormalize(Char *);
void dopushd(Char **, struct command *);
void dopopd(Char **, struct command *);
Char *Dfix1(Char *);
void heredoc(Char *);
void doexec(Char **, struct command *);
void dohash(Char **, struct command *);
void dounhash(Char **, struct command *);
void dowhich(Char **, struct command *);
void execash(Char **, struct command *);
void hashstat(Char **, struct command *);
void xechoit(Char **);
int expr(Char ***);
int exp0(Char ***, bool);
static void catn(Char *, Char *, int);
static void copyn(Char *, Char *, int);
static Char filetype(Char *, Char *);
static void print_by_column(Char *, Char *[], int);
static Char *tilde(Char *, Char *);
static void extract_dir_and_name(Char *, Char *, Char *);
static Char *getentry(DIR *, int);
static void free_items(Char **, int);
static int tsearch(Char *, COMMAND, int);
static int recognize(Char *, Char *, int, int);
static int is_prefix(Char *, Char *);
static int is_suffix(Char *, Char *);
static int ignored(Char *);
static Char *
static Char word[BUFSIZ];
Char *cp;
Char *word;
Char *word;
catn(Char *des, Char *src, int count)
copyn(Char *des, Char *src, int count)
static Char
filetype(Char *dir, Char *file)
Char path[PATH_MAX];
Strlcpy(path, dir, sizeof path/sizeof(Char));
catn(path, file, sizeof(path) / sizeof(Char));
print_by_column(Char *dir, Char *items[], int count)
static Char *
tilde(Char *new, Char *old)
Char *o, *p;
static Char person[40];
extract_dir_and_name(Char *path, Char *dir, Char *name)
Char *p;
static Char *
free_items(Char **items, int numitems)
tsearch(Char *word, COMMAND command, int max_word_length)
Char tilded_dir[PATH_MAX], dir[PATH_MAX];
Char name[MAXNAMLEN + 1], extended_name[MAXNAMLEN + 1];
Char *entry;
Char **items = NULL;
items[numitems] = xreallocarray(NULL, (Strlen(entry) + 1), sizeof(Char));
recognize(Char *extended_name, Char *entry, int name_length, int numitems)
Char *x, *ent;
is_prefix(Char *check, Char *template)
is_suffix(Char *check, Char *template)
Char *c, *t;
tenex(Char *inputline, int inputline_size)
ignored(Char *entry)
Char **cp;
static Char *cl_lastw(struct cmdline *);
static struct limits *findlim(Char *);
static rlim_t getval(struct limits *, Char **);
static void limtail(Char *, char *);
static void plim(struct limits *, Char);
static int setlim(struct limits *, Char, rlim_t);
findlim(Char *cp)
dolimit(Char **v, struct command *t)
getval(struct limits *lp, Char **v)
Char *cp = *v++;
limtail(Char *cp, char *str)
plim(struct limits *lp, Char hard)
doonintr(Char **v, struct command *t)
dounlimit(Char **v, struct command *t)
Char *cp;
Char hard = 0;
Char *vv = v[1];
setlim(struct limits *lp, Char hard, rlim_t limit)
dosuspend(Char **v, struct command *t)
static Char **gv = NULL;
doeval(Char **v, struct command *t)
Char **oevalvec;
Char *oevalp;
Char **savegv = gv;
donohup(Char **v, struct command *t)
dozip(Char **v, struct command *t)
doalias(Char **v, struct command *t)
Char *p;
unalias(Char **v, struct command *t)
dologout(Char **v, struct command *t)
dologin(Char **v, struct command *t)
doif(Char **v, struct command *kp)
Char **vv;
doelse(Char **v, struct command *t)
dogoto(Char **v, struct command *t)
Char *lp;
gotolab(Char *lab)
doswitch(Char **v, struct command *t)
Char *cp, *lp;
dobreak(Char **v, struct command *t)
doexit(Char **v, struct command *t)
doforeach(Char **v, struct command *t)
Char *cp, *sp;
dowhile(Char **v, struct command *t)
doend(Char **v, struct command *t)
docontin(Char **v, struct command *t)
dorepeat(Char **v, struct command *kp)
doswbrk(Char **v, struct command *t)
static void search(int, int, Char *);
srchx(Char *cp)
static int getword(Char *);
static int keyword(Char *);
static Char Stype;
static Char *Sgoal;
search(int type, int level, Char *goal)
Char wordbuf[BUFSIZ];
Char *aword = wordbuf;
Char *cp;
static void xecho(int, Char **);
static void Unsetenv(Char *);
Char *cp = t->t_dcom[0];
getword(Char *wp)
Char *owp = wp;
keyword(Char *wp)
static Char STRif[] = {'i', 'f', '\0'};
static Char STRwhile[] = {'w', 'h', 'i', 'l', 'e', '\0'};
static Char STRswitch[] = {'s', 'w', 'i', 't', 'c', 'h', '\0'};
doecho(Char **v, struct command *t)
doglob(Char **v, struct command *t)
xecho(int sep, Char **v)
Char *cp;
dosetenv(Char **v, struct command *t)
Char *vp, *lp;
Char **ep;
dounsetenv(Char **v, struct command *t)
Char **ep, *p, *n, *name;
name = xreallocarray(NULL, maxi + 1, sizeof(Char));
Setenv(Char *name, Char *val)
Char **ep = STR_environ;
Char *cp, *dp;
Char *blk[2];
Char **oep = ep;
blkfree((Char **) environ);
blkfree((Char **) environ);
Unsetenv(Char *name)
Char **ep = STR_environ;
Char *cp, *dp;
Char **oep = ep;
doumask(Char **v, struct command *t)
Char *cp = v[1];
if (gethdir(gstart, &gbuf[sizeof(gbuf)/sizeof(Char)] - gstart)) {
globbrace(Char *s, Char *p, Char ***bl)
Char *pm, *pe, *lm, *pl;
Char **nv, **vl;
Char gbuf[PATH_MAX];
nv = vl = xreallocarray(NULL, size, sizeof(Char *));
Char savec = *pm;
(void) Strlcpy(lm, pl, &gbuf[sizeof(gbuf)/sizeof(Char)] - lm);
nv = xreallocarray(nv, size, sizeof(Char *));
expbrace(Char ***nvp, Char ***elp, int size)
Char **vl, **el, **nv, *s;
Char *b;
Char **vp, **bp;
Char **bl;
nv = xreallocarray(nv, size, sizeof(Char *));
static Char **
globexpand(Char **v)
Char *s;
Char **nv, **vl, **el;
nv = vl = xreallocarray(NULL, size, sizeof(Char *));
nv = xreallocarray(nv, size, sizeof(Char *));
nv = xreallocarray(nv, size, sizeof(Char *));
static Char *
handleone(Char *str, Char **vl, int action)
Char *cp, **vlp = vl;
static Char **
libglob(Char **vl)
Char *
globone(Char *str, int action)
Char *v[2], **vl, **vo;
Char **
globall(Char **v)
Char **vl, **vo;
gargv = xreallocarray(NULL, gargsiz, sizeof(Char *));
rscan(Char **t, void (*f)(int))
Char *p;
trim(Char **t)
Char *p;
tglob(Char **t)
Char *p, c;
Char **
dobackp(Char *cp, bool literal)
Char *lp, *rp;
Char *ep, word[PATH_MAX];
pargv = xreallocarray(NULL, pargsiz, sizeof(Char *));
backeval(Char *cp, bool literal)
Char *ip;
Char *fakecom[2], ibuf[BUFSIZ];
Char **gargv = NULL;
Char **pargv = NULL;
pargv = xreallocarray(pargv, pargsiz, sizeof(Char *));
static Char *globtilde(Char **, Char *);
Gmatch(Char *string, Char *pattern)
Char **blk, **p;
static Char **libglob(Char **);
blk = xreallocarray(NULL, GLOBSPACE, sizeof(Char *));
static Char **globexpand(Char **);
pmatch(Char *string, Char *pattern)
Char stringc, patternc;
static int globbrace(Char *, Char *, Char ***);
Char rangec;
static void expbrace(Char ***, Char ***, int);
static int pmatch(Char *, Char *);
static void backeval(Char *, bool);
Gcat(Char *s1, Char *s2)
Char *p, *q;
gargv = xreallocarray(gargv, gargsiz, sizeof(Char *));
p = gargv[gargc - 1] = xreallocarray(NULL, n, sizeof(Char));
static Char *
if (!*(Char **)a) /* check for NULL */
return (*(Char **)b ? 1 : 0);
if (!*(Char **)b)
(void) strlcpy(buf, short2str(*(Char **)a), sizeof buf);
return ((int) strcoll(buf, short2str(*(Char **)b)));
globtilde(Char **nv, Char *s)
Char gbuf[PATH_MAX], *gstart, *b, *u, *e;
dohist(Char **v, struct command *t)
Char *vp = *v;
Char *cp;
Char *p = cp;
Char *alvecp = NULL;
Char *np;
static Char labuf[BUFSIZ];
if (np < &lhsb[sizeof(lhsb) / sizeof(Char) - 2])
if (np < &lhsb[sizeof(lhsb) / sizeof(Char) - 2])
findev(Char *cp, bool anyarg)
Char *dp;
Char *p, *q;
setexclp(Char *cp)
static Char getCtmp;
if (evalvec == (Char **) 1) {
evalvec = (Char **) 1;
if (arginp == (Char *) 1 || onelflg == 1) {
arginp = (Char *) 1;
Char ttyline[BUFSIZ];
Char **nfbuf = xcalloc(fblocks + 2, sizeof(*nfbuf));
fbuf[fblocks] = xcalloc(BUFSIZ, sizeof(Char));
memcpy(fbuf[buf] + off, ttyline, c * sizeof(Char));
Char *ptr = fbuf[buf] + off;
fbuf[0] = xcalloc(BUFSIZ, sizeof(Char));
static Char *
Char c, c1;
Char *wp;
Char wbuf[BUFSIZ];
Char c;
Char *np, *ep;
Char name[4 * MAXVARLEN + 1];
static Char *word(void);
*findev(Char *, bool);
static void setexclp(Char *);
addla(Char *cp)
Char buf[BUFSIZ];
(sizeof(labuf) - 4) / sizeof(Char)) {
(void) Strlcpy(buf, lap, sizeof buf/sizeof(Char));
(void) Strlcpy(labuf, cp, sizeof labuf/sizeof(Char));
(void) Strlcat(labuf, buf, sizeof labuf/sizeof(Char));
static Char lhsb[32];
static Char slhs[32];
static Char rhsb[64];
static int matchs(Char *, Char *);
static Char *subword(Char *, int, bool *);
Char *cp;
Char orhsb[sizeof(rhsb) / sizeof(Char)];
(void) Strlcpy(lhsb, slhs, sizeof(lhsb)/sizeof(Char));
if (cp > &lhsb[sizeof(lhsb) / sizeof(Char) - 2]) {
(void) Strlcpy(orhsb, cp, sizeof(orhsb)/sizeof(Char));
if (cp > &rhsb[sizeof(rhsb) / sizeof(Char) - 2]) {
(void) Strlcpy(slhs, lhsb, sizeof(slhs)/sizeof(Char));
Char *tword, *otword;
static Char *
static Char peekc = 0, peekd = 0;
subword(Char *cp, int type, bool *adid)
Char wbuf[BUFSIZ];
Char *wp, *mp, *np;
static Char peekread = 0;
static Char *exclp = NULL;
sizeof(wbuf)/sizeof(Char) - (wp - wbuf));
sizeof(wbuf)/sizeof(Char) - (wp - wbuf));
Char *
domod(Char *cp, int type)
Char *wp, *xp;
matchs(Char *str, Char *pat)
blkfree(Char **av0)
Char **av = av0;
Char **
saveblk(Char **v)
Char **newv = xcalloc(blklen(v) + 1, sizeof(*newv));
Char **onewv = newv;
Char **
blkspl(Char **up, Char **vp)
Char **wp = xcalloc(blklen(up) + blklen(vp) + 1, sizeof(*wp));
Char
lastchr(Char *cp)
lshift(Char **v, int c)
Char **u;
number(Char *cp)
Char **
copyblk(Char **v)
Char **nv = xcalloc(blklen(v) + 1, sizeof(*nv));
Char *
strip(Char *cp)
Char *dp = cp;
Char *
quote(Char *cp)
Char *dp = cp;
udvar(Char *name)
prefix(Char *sub, Char *str)
Char **
blkend(Char **up)
blkpr(FILE *fp, Char **av)
blklen(Char **av)
Char **
blkcpy(Char **oav, Char **bv)
Char **av = oav;
Char **
blkcat(Char **up, Char **vp)
Char *cp = alout.next->word;
Char **av;
Char **v;
pkill(Char **v, int signum)
Char *cp;
pfind(Char *cp)
Char *dp;
donotify(Char **v, struct command *t)
Char *jobcommand[3];
dowait(Char **v, struct command *t)
static Char command[PMAXLEN + 4];
static Char *cmdp;
Char **argp;
pads(Char *cp)
static void pads(Char *);
static void pkill(Char **v, int);
dojobs(Char **v, struct command *t)
dofg(Char **v, struct command *t)
dofg1(Char **v, struct command *t)
dobg(Char **v, struct command *t)
dobg1(Char **v, struct command *t)
dostop(Char **v, struct command *t)
dokill(Char **v, struct command *t)
Char *p_command; /* first PMAXLEN chars of command */
blkfree((Char **) Vt);
static Char *
splicepipe(struct command *t, Char *cp) /* word after < or > */
Char *blk[2];
Char **pv;
static Char *splicepipe(struct command *t, Char *);
Char **av = blkspl(t->t_dcom, &pv[1]);
Char *cp;
(Strlen(t->t_dcom[0] + 1) + 1) * sizeof(Char));
Char **e = v;
Char *pn = value(STRhistchars);
Char *cp;
static Char *
getinx(Char *cp, int *ip)
asx(Char *vp, int subscr, Char *p)
getvx(Char *vp, int subscr)
dolet(Char **v, struct command *t)
Char *p;
Char *vp, c, op;
static Char *
xset(Char *cp, Char ***vp)
Char *dp;
static Char *
operate(int op, Char *vp, Char *p)
Char opr[2];
Char *vec[5];
Char **v = vec;
Char **vecp = v;
Char *
getn(Char *cp)
Char *
value1(Char *var, struct varent *head)
madrof(Char *pat, struct varent *vp)
adrof1(Char *name, struct varent *v)
static Char *getinx(Char *, int *);
set(Char *var, Char *val)
Char **vec = xreallocarray(NULL, 2, sizeof(*vec));
static void asx(Char *, int, Char *);
set1(Char *var, Char **vec, struct varent *head)
Char **oldv = vec;
*getvx(Char *, int);
setq(Char *name, Char **vec, struct varent *p)
static Char *xset(Char *, Char ***);
static Char *operate(int, Char *, Char *);
unset(Char **v, struct command *t)
*madrof(Char *, struct varent *);
unset1(Char *v[], struct varent *head)
unsetv(Char *var)
static void exportpath(Char **);
setNS(Char *cp)
shift(Char **v, struct command *t)
Char *name;
exportpath(Char **val)
Char exppath[BUFSIZ];
(void) Strlcat(exppath, *val++, sizeof exppath/sizeof(Char));
(void) Strlcat(exppath, STRcolon, sizeof exppath/sizeof(Char));
doset(Char **v, struct command *t)
Char *p;
Char *vp, op;
Char **vecp;
*dst++ = (Char) ((unsigned char) *src++);
sdst = xreallocarray(sdst, dstsize, sizeof(Char));
short2str(Char *src)
Strlcpy(Char *dst, const Char *src, size_t siz)
Char *d = dst;
const Char *s = src;
Strlcat(Char *dst, const Char *src, size_t siz)
Char *d = dst;
const Char *s = src;
return(dlen + Strlen((Char *)s));
Char *
Strchr(Char *str, int ch)
Char *
Strrchr(Char *str, int ch)
Char *rstr;
Strlen(Char *str)
Strcmp(Char *str1, Char *str2)
Strncmp(Char *str1, Char *str2, size_t n)
Char *
Strsave(Char *s)
Char *n;
Char *p;
n = p = xreallocarray(NULL, p - s, sizeof(Char));
Char *
Strspl(Char *cp, Char *dp)
Char *ep;
Char *p, *q;
ep = xreallocarray(NULL, ((p - cp) + (q - dp) - 1), sizeof(Char));
Char *
Strend(Char *cp)
Char *
Strstr(Char *s, Char *t)
Char *ss = s;
Char *tt = t;
short2qstr(Char *src)
vis_str(Char *cp)
Char *dp;
Char **
Char **sdst, **dst;
sdst = dst = xreallocarray(NULL, n + 1, sizeof(Char *));
short2blk(Char **src)
Char *
static Char *sdst;
Char *dst, *edst;
sdst = xreallocarray(NULL, dstsize, sizeof(Char));
dotime(Char **v, struct command *t)
donice(Char **v, struct command *t)
Char *cp;
extern Char *MALLOC ANSI((size_t));
Char *
memcpy_D2A(a, b, len) Char *a; Char *b; size_t len;
g_lstat(Char *fn, struct stat *sb, glob_t *pglob)
g_stat(Char *fn, struct stat *sb, glob_t *pglob)
static Char *
g_strchr(const Char *str, int ch)
return ((Char *)str);
g_Ctoc(const Char *str, char *buf, size_t len)
qprintf(const char *str, Char *s)
Char *p;
#define CHAR(c) ((Char)((c)&M_ASCII))
#define META(c) ((Char)((c)|M_QUOTE))
static int g_Ctoc(const Char *, char *, size_t);
static int g_lstat(Char *, struct stat *, glob_t *);
static DIR *g_opendir(Char *, glob_t *);
static Char *g_strchr(const Char *, int);
static int g_strncmp(const Char *, const char *, size_t);
static int g_stat(Char *, struct stat *, glob_t *);
static int glob0(const Char *, glob_t *, struct glob_lim *);
static int glob1(Char *, Char *, glob_t *, struct glob_lim *);
static int glob2(Char *, Char *, Char *, Char *, Char *, Char *,
static int glob3(Char *, Char *, Char *, Char *, Char *,
Char *, Char *, glob_t *, struct glob_lim *);
static int globextend(const Char *, glob_t *, struct glob_lim *,
static const Char *
globtilde(const Char *, Char *, size_t, glob_t *);
static int globexp1(const Char *, glob_t *, struct glob_lim *);
static int globexp2(const Char *, const Char *, glob_t *,
static int match(Char *, Char *, Char *);
static void qprintf(const char *, Char *);
Char *bufnext, *bufend, patbuf[PATH_MAX];
globexp1(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
const Char* ptr = pattern;
if ((ptr = (const Char *) g_strchr(ptr, LBRACE)) != NULL)
globexp2(const Char *ptr, const Char *pattern, glob_t *pglob,
Char *lm, *ls;
const Char *pe, *pm, *pl;
Char patbuf[PATH_MAX];
static const Char *
globtilde(const Char *pattern, Char *patbuf, size_t patbuf_len, glob_t *pglob)
const Char *p;
Char *b, *eb;
g_strncmp(const Char *s1, const char *s2, size_t n)
rv = *(Char *)s1 - *(const unsigned char *)s2++;
g_charclass(const Char **patternp, Char **bufnextp)
const Char *pattern = *patternp + 1;
Char *bufnext = *bufnextp;
const Char *colon;
*bufnext++ = (Char)(cc - &cclasses[0]);
glob0(const Char *pattern, glob_t *pglob, struct glob_lim *limitp)
const Char *qpatnext;
Char *bufnext, patbuf[PATH_MAX];
glob1(Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp)
Char pathbuf[PATH_MAX];
glob2(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
Char *pattern, Char *pattern_last, glob_t *pglob, struct glob_lim *limitp)
Char *p, *q;
glob3(Char *pathbuf, Char *pathbuf_last, Char *pathend, Char *pathend_last,
Char *pattern, Char *restpattern, Char *restpattern_last, glob_t *pglob,
Char *dc;
globextend(const Char *path, glob_t *pglob, struct glob_lim *limitp,
const Char *p;
match(Char *name, Char *pat, Char *patend)
Char c, k;
Char *nextp = NULL;
Char *nextn = NULL;
Char idx = *pat & M_MASK;
g_opendir(Char *str, glob_t *pglob)
str = va_arg(va, const Char *);
str = va_arg(va, const Char *);
retval = history_prev_string(h, ev, va_arg(va, const Char *));
retval = history_next_string(h, ev, va_arg(va, const Char *));
const Char *line = va_arg(va, const Char *);
const Char *s;
Char *str;
const Char *);
const Char *);
static int history_def_enter(void *, TYPE(HistEvent) *, const Char *);
static int history_def_add(void *, TYPE(HistEvent) *, const Char *);
static int history_def_insert(history_t *, TYPE(HistEvent) *, const Char *);
static const Char *const he_errlist[] = {
history_def_add(void *p, TYPE(HistEvent) *ev, const Char *str)
Char *s;
history_def_insert(history_t *h, TYPE(HistEvent) *ev, const Char *str)
history_def_enter(void *p, TYPE(HistEvent) *ev, const Char *str)
typedef int (*history_efun_t)(void *, TYPE(HistEvent) *, const Char *);
history_prev_string(TYPE(History) *h, TYPE(HistEvent) *ev, const Char *str)
history_next_string(TYPE(History) *h, TYPE(HistEvent) *ev, const Char *str)
const Char *str;
str = va_arg(va, const Char *);
FUN(tok,init)(const Char *ifs)
int *argc, const Char ***argv, int *cursorc, int *cursoro)
const Char *ptr;
Char *s = reallocarray(tok->wspace, size, sizeof(*s));
Char **p;
*argv = (const Char **)tok->argv;
FUN(tok,str)(TYPE(Tokenizer) *tok, const Char *line, int *argc,
const Char ***argv)
Char *ifs; /* In field separator */
Char **argv; /* Argument list */
Char *wptr, *wmax; /* Space and limit on the word buffer */
Char *wstart; /* Beginning of next word */
Char *wspace; /* Space of word buffer */