Char
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 STRmZ[] = { '-', 'Z', '\0' };
Char STRmn[] = { '-', 'n', '\0' };
Char STRmquestion[] = { '?' | QUOTE, ' ', '\0' };
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 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 STRsymcent[] = { '%', ' ', '\0' };
Char STRsymhash[] = { '#', ' ', '\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 STRLANG[] = { 'L', 'A', 'N', 'G', '\0' };
Char STRLC_CTYPE[] = { 'L', 'C', '_', 'C', 'T', 'Y', 'P', '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 STRedit[] = { 'e', 'd', 'i', 't', '\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 *jobargv[2] = {STRjobs, 0};
Char **v;
Char *arginp;
Char *ffile;
Char *shtemp;
Char *doldol;
dosource(Char **v, struct command *t)
Char buf[BUFSIZE], *f;
Char **vp;
Char *gointr;
gethdir(Char *home)
Char *h;
Char *lap;
static Char **
Char **blk, **blkp;
blkp = blk = xmalloc((size_t) sizeof(Char *) * 10);
Char *pargs;
Char *cp;
Char *pargcp;
Char *cp;
Char HIST;
Char HISTSUB;
Char *Vsav;
Char *Vdp;
Char *Vexpath;
Char **evalvec;
Char *evalp;
Char *word_chars;
Char *STR_SHELLPATH;
Char *STR_BSHELL;
Char *STR_WORD_CHARS;
Char **STR_environ;
Char *dumphist[] = {STRhistory, STRmh, 0, 0};
Char *tildehist[] = {STRsource, STRmh, STRtildothist, 0};
static int srccat(Char *, Char *);
static Char **defaultpath(void);
Char *cp;
importpath(Char *cp)
Char *dp, **pv;
srccat(Char *cp, Char *dp)
Char *ep;
Char *oarginp, *oevalp, **oevalvec, *ogointr;
Char OHIST;
Char HISTSUB;
Char buf[BUFSIZE], hbuf[BUFSIZE], *hfile;
Char *s;
extern Char *arginp; /* Argument input for sh -c and internal `xx` */
extern Char *ffile; /* Name of shell file for $0 */
extern Char *shtemp; /* Temp name for << shell files in /tmp */
extern Char *doldol; /* Character pid for $$ */
extern Char *gointr; /* Label for an onintr transfer */
#define CHAR ((Char)0xff)
#define QUOTE ((Char)0x8000) /* 16nth char bit used for 'ing */
#define TRIM ((Char)0x7fff) /* Mask to strip quote bit */
#define CHAR ((Char)0x7f)
#define QUOTE ((Char)0x80) /* Eighth char bit used for 'ing */
#define TRIM ((Char)0x7f) /* Mask to strip quote bit */
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 */
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;
skipargs(Char ***v, const char *str)
Char **n, *s;
dodirs(Char **v, struct command *t)
Char *hp, *s;
dtildepr(Char *home, Char *dir)
Char *
dnormalize(Char *cp)
Char *dp, *cwd;
sizeof(Char));
dochngd(Char **v, struct command *t)
Char *cp;
static Char *
dgoto(Char *cp)
Char *dp;
Char *p, *q;
(size_t)(cwdlen + (size_t)(p - cp) + 1), sizeof(Char));
static Char *
dfollow(Char *cp)
Char *dp;
Char **cdp;
Char *p;
Char buf[MAXPATHLEN];
dopushd(Char **v, struct command *t)
Char *ccp;
dfind(Char *cp)
Char *ep;
dopopd(Char **v, struct command *t)
static struct directory *dfind(Char *);
static Char *dfollow(Char *);
static Char *dgoto(Char *);
static void skipargs(Char ***, const char *);
Char *
dcanon(Char *cp, Char *p)
Char slink[MAXPATHLEN];
Char *newcp, *sp;
Char *p1, *p2; /* general purpose */
static void dset(Char *);
Char tmpdir[MAXPATHLEN];
(size_t)((sp - cp) + cc + (p1 - p)), sizeof(Char));
(size_t)(cc + (p1 - p)), sizeof(Char));
dinit(Char *hp)
(size_t)((sp - cp) + cc + (p1 - p)), sizeof(Char));
Char *cp;
(size_t)(cc + (p1 - p)), sizeof(Char));
static Char *home_ptr = NULL;
sp = (Char *) - 1;
if (*p2 && sp == (Char *) -1) {
Char *di_name; /* actual name */
Char *p, **pp;
Char *
Dfix1(Char *cp)
Char *Dv[2];
Dfix2(Char **v)
static Char *
Dpack(Char *wbuf, Char *wp)
*wp++ = (Char)c;
Char wbuf[BUFSIZE], *wp;
*wp++ = (Char)c, --i;
*wp++ = (Char)(c == '`' ? '`' : (c | QUOTE));
*wp++ = (Char)(c | QUOTE);
*wp++ = (Char)c;
static Char *nulvec[] = {0};
dolerror(Char *s)
static Char *dolbang = NULL;
Char name[4*MAXVARLEN+1];
Char wbuf[BUFSIZE];
Char *np;
*np++ = (Char)c;
if (np >= &name[sizeof(name) / sizeof(Char) - 2])
*np++ = (Char)c;
Char *cp = putn(upb - lwb + 1);
static Char *Dcp, **Dvp; /* Input vector for Dreadc */
dolmod[dolnmod++] = (Char)c;
dolmod[dolnmod++] = (Char)delim;
dolmod[dolnmod++] = (Char)c;
dolmod[dolnmod++] = (Char)c;
setDolp(Char *cp)
Char *dp;
Char *lhsub, *rhsub, *np;
dolmod[i] = rhsub[-1] = (Char)delim;
static Char dolmod[MAXMOD]; /* : modifier character */
static Char *dolp; /* Remaining chars from this word */
static Char **dolnxt; /* Further words */
heredoc(Char *term)
Char obuf[BUFSIZE], lbuf[BUFSIZE], mbuf[BUFSIZE];
Char *Dv[2], *lbp, *obp, *mbp, **vp;
static void Dfix2(Char **);
*lbp++ = (Char)c;
static Char *Dpack(Char *, Char *);
*obp++ = (Char)c;
__dead static void dolerror(Char *);
*mbp++ = (Char)c;
static void setDolp(Char *);
Char **v;
static Char *justabs[] = {STRNULL, 0};
static void texec(Char *, Char **);
static int hashname(Char *);
static int tellmewhat(struct wordent *, Char *);
static int executable(Char *, Char *, int);
static int iscommand(Char *);
doexec(Char **v, struct command *t)
Char *blk[2], **av, *dp, **pv, *sav;
texec(Char *sf, Char **st)
Char *lastsh[2], **vp, *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, *sav;
executable(Char *dir, Char *name, int dir_ok)
Char path[MAXPATHLEN + 1], *dp, *sp;
dowhich(Char **v, struct command *c)
tellmewhat(struct wordent *lexp, Char *str)
Char *cmd, *s0, *s1, *s2;
Char qc;
*s1++ = (Char)(*s2++ | QUOTE);
*s1++ = (Char)(*s2++ | QUOTE);
Char **pv;
static Char *expath; /* Path for exerr */
exp1(Char ***vp, int ignore)
csh_exp2(Char ***vp, int ignore)
exp2a(Char ***vp, int ignore)
exp2b(Char ***vp, int ignore)
exp2c(Char ***vp, int ignore)
Char *p1, *p2;
static Char *
exp3(Char ***vp, int ignore)
Char *p1, *p2;
static Char *
exp3a(Char ***vp, int ignore)
Char *op, *p1, *p2;
static Char *
exp4(Char ***vp, int ignore)
Char *p1, *p2;
Char *op;
static Char *
exp5(Char ***vp, int ignore)
Char *p1, *p2;
Char *op;
static Char *
exp6(Char ***vp, int ignore)
Char *cp, *dp, *ep;
Char *fakecom[2];
Char **v;
evalav(Char **v)
isa(Char *cp, int what)
egetn(Char *cp)
etraci(char *str, int i, Char ***vp)
etracc(char *str, Char *cp, Char ***vp)
static int exp1(Char ***, int);
static int csh_exp2(Char ***, int);
static int exp2a(Char ***, int);
static int exp2b(Char ***, int);
static int exp2c(Char ***, int);
static Char *exp3(Char ***, int);
static Char *exp3a(Char ***, int);
static Char *exp4(Char ***, int);
static Char *exp5(Char ***, int);
static Char *exp6(Char ***, int);
static void evalav(Char **);
static int isa(Char *, int);
static int egetn(Char *);
static void etracc(char *, Char *, Char ***);
static void etraci(char *, int, Char ***);
expr(Char ***vp)
exp0(Char ***vp, int ignore)
void execash(Char **, struct command *);
void hashstat(Char **, struct command *);
void xechoit(Char **);
int expr(Char ***);
int exp0(Char ***, int);
ssize_t tenex(Char *, size_t);
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 *);
__dead void dologin(Char **, struct command *);
__dead void dologout(Char **, struct command *);
void donohup(Char **, struct command *);
void doonintr(Char **, struct command *);
void doprintf(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 *, int);
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 **, size_t);
int number(Char *);
int prefix(Char *, Char *);
Char **saveblk(Char **);
Char *strip(Char *);
Char *quote(Char *);
__dead 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 *);
struct process *pfind(Char *);
struct varent*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 *);
Char *s_strchr(const Char *, int);
Char *s_strrchr(const Char *, int);
Char *s_strcat(Char *, const Char *);
Char *s_strncat(Char *, const Char *, size_t);
Char *s_strcpy(Char *, const Char *);
Char *s_strncpy(Char *, const Char *, size_t);
Char *s_strspl(const Char *, const Char *);
size_t s_strlen(const Char *);
int s_strcmp(const Char *, const Char *);
int s_strncmp(const Char *, const Char *, size_t);
Char *s_strsave(const Char *);
Char *s_strend(const Char *);
Char *s_strstr(const Char *, const Char *);
Char *str2short(const char *);
Char **blk2short(char **);
char *short2str(const Char *);
char **short2blk(Char * const *);
char *short2qstr(const Char *);
char *vis_str(const Char *);
int gethdir(Char *);
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 *);
__dead void doexec(Char **, struct command *);
void dohash(Char **, struct command *);
void dounhash(Char **, struct command *);
void dowhich(Char **, struct command *);
static int is_prefix(Char *, Char *);
static int is_suffix(Char *, Char *);
static int ignored(Char *);
pushback(Char *string)
Char *p;
catn(Char *des, Char *src, size_t count)
copyn(Char *des, Char *src, size_t count)
static Char
filetype(Char *dir, Char *file)
Char path[MAXPATHLEN];
catn(Strcpy(path, dir), file, sizeof(path) / sizeof(Char));
print_by_column(Char *dir, Char *items[], size_t count)
static Char *
tilde(Char *new, Char *old)
static Char person[40];
Char *o, *p;
print_recognized_stuff(Char *recognized_part)
extract_dir_and_name(Char *path, Char *dir, Char *name)
Char *p;
static Char *
free_items(Char **items, size_t numitems)
tsearch(Char *word, COMMAND command, size_t max_word_length)
Char dir[MAXPATHLEN + 1], extended_name[MAXNAMLEN + 1];
Char name[MAXNAMLEN + 1], tilded_dir[MAXPATHLEN + 1];
Char *entry;
Char **items = NULL;
(size_t) (Strlen(entry) + 1), sizeof(Char));
recognize(Char *extended_name, Char *entry, size_t name_length, size_t numitems)
Char *ent, *x;
is_prefix(Char *check, Char *template)
is_suffix(Char *check, Char *template)
Char *c, *t;
tenex(Char *inputline, size_t inputline_size)
static Char delims[] = {' ', '\'', '"', '\t', ';', '&', '<',
Char *str_end, *word_start, last_Char, should_retype;
ignored(Char *entry)
Char **cp;
static int pushback(Char *);
static void catn(Char *, Char *, size_t);
static void copyn(Char *, Char *, size_t);
static Char filetype(Char *, Char *);
static void print_by_column(Char *, Char *[], size_t);
static Char *tilde(Char *, Char *);
static void print_recognized_stuff(Char *);
static void extract_dir_and_name(Char *, Char *, Char *);
static Char *getentry(DIR *, int);
static void free_items(Char **, size_t);
static size_t tsearch(Char *, COMMAND, size_t);
static int recognize(Char *, Char *, size_t, size_t);
Setenv(Char *name, Char *val)
Char *blk[2], *cp, *dp, **ep, **oep;
blkfree((Char **)environ);
blkfree((Char **)environ);
Unsetenv(Char *name)
Char *cp, *dp, **ep, **oep;
doumask(Char **v, struct command *t)
Char *cp;
static const struct limits *findlim(Char *);
static RLIM_TYPE getval(const struct limits *, Char **);
static void limtail(Char *, const char *);
static void plim(const struct limits *, Char);
static int setlim(const struct limits *, Char, RLIM_TYPE);
findlim(Char *cp)
dolimit(Char **v, struct command *t)
getval(const struct limits *lp, Char **v)
Char *cp;
limtail(Char *cp, const char *str)
plim(const struct limits *lp, Char hard)
dounlimit(Char **v, struct command *t)
Char hard;
setlim(const struct limits *lp, Char hard, RLIM_TYPE limit)
doonintr(Char **v, struct command *t)
dosuspend(Char **v, struct command *t)
Char *cp, *vv;
static Char **gv = NULL;
doeval(Char **v, struct command *t)
Char *oevalp, **oevalvec, **savegv;
doprintf(Char **v, struct command *t)
blkfree((Char **)c);
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)
srchx(Char *cp)
static Char Stype;
static Char *Sgoal;
search(int type, int level, Char *goal)
Char wordbuf[BUFSIZE];
Char *aword, *cp;
Stype = (Char)type;
static void search(int, int, Char *);
static int getword(Char *);
static int keyword(Char *);
static void xecho(int, Char **);
static void Unsetenv(Char *);
getword(Char *wp)
Char *owp;
*wp++ = (Char)c;
Char *cp;
keyword(Char *wp)
static Char STRswitch[] = {'s', 'w', 'i', 't', 'c', 'h', '\0'};
static Char STRwhile[] = {'w', 'h', 'i', 'l', 'e', '\0'};
static Char STRif[] = {'i', 'f', '\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 *lp, *vp;
Char **ep;
dounsetenv(Char **v, struct command *t)
static Char *name = NULL;
Char **ep, *p, *n;
name = xreallocarray(NULL, (size_t)(maxi + 1), sizeof(Char));
Char gbuf[MAXPATHLEN], *b, *e, *gstart, *u;
globbrace(Char *s, Char *p, Char ***bl)
Char gbuf[MAXPATHLEN];
Char *lm, *pe, *pl, *pm, **nv, **vl;
nv = vl = xreallocarray(NULL, sizeof(Char *), (size_t)size);
Char savec = *pm;
nv = xreallocarray(nv, (size_t)size, sizeof(Char *));
expbrace(Char ***nvp, Char ***elp, size_t size)
Char **ex, **nv, *s, **vl;
Char *b, **bp, **vp;
Char **bl;
nv = xreallocarray(nv, size, sizeof(Char *));
static Char **
globexpand(Char **v)
Char **ex, **nv, *s, **vl;
nv = vl = xreallocarray(NULL, sizeof(Char *), size);
nv = xreallocarray(nv, size, sizeof(Char *));
nv = xreallocarray(nv, size, sizeof(Char *));
static Char *
handleone(Char *str, Char **vl, int action)
Char *cp, **vlp;
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, sizeof(Char *), (size_t)gargsiz);
rscan(Char **t, void (*f)(int))
Char *p;
trim(Char **t)
Char *p;
tglob(Char **t)
Char *p, c;
Char **
dobackp(Char *cp, int literal)
Char word[MAXPATHLEN], *ep, *lp, *rp;
pargv = xreallocarray(NULL, sizeof(Char *), (size_t)pargsiz);
backeval(Char *cp, int literal)
Char ibuf[BUFSIZE], *fakecom[2], *ip;
Char **gargv = NULL;
Char **pargv = NULL;
*pargcp++ = (Char)c;
pargv = xreallocarray(pargv, (size_t)pargsiz, sizeof(Char *));
Gmatch(Char *string, Char *pattern)
Char **blk, **p;
blk = xreallocarray(NULL, GLOBSPACE, sizeof(Char *));
pmatch(const Char *name, const Char *pat)
Char patc, namec, c;
const Char *nameNext, *nameStart, *nameEnd, *patNext;
static Char *globtilde(Char **, Char *);
static Char *handleone(Char *, Char **, int);
static Char **libglob(Char **);
Gcat(Char *s1, Char *s2)
static Char **globexpand(Char **);
Char *p, *q;
static int globbrace(Char *, Char *, Char ***);
gargv = xreallocarray(gargv, (size_t)gargsiz, sizeof(Char *));
p = gargv[gargc - 1] = xreallocarray(NULL, (size_t)n, sizeof(Char));
static void expbrace(Char ***, Char ***, size_t);
const Char * const *a = va;
const Char * const *b = vb;
static int pmatch(const Char *, const Char *);
static void backeval(Char *, int);
static Char *
globtilde(Char **nv, Char *s)
dohist(Char **v, struct command *t)
Char *vp = *v;
Char *cp;
Char *p = cp;
matchs(Char *str, Char *pat)
Char **alvec, *alvecp;
Char *np;
static Char labuf[BUFSIZE];
if (np < &lhsb[sizeof(lhsb) / sizeof(Char) - 2])
*np++ = (Char)c;
if (np < &lhsb[sizeof(lhsb) / sizeof(Char) - 2])
*np++ = (Char)c;
findev(Char *cp, int anyarg)
Char *dp, *p, *q;
setexclp(Char *cp)
if (evalvec == (Char **) 1) {
evalvec = (Char **) 1;
if (arginp == (Char *) 1 || onelflg == 1) {
arginp = (Char *) 1;
Char ttyline[BUFSIZE];
Char **nfbuf;
fbuf[fblocks] = xcalloc(BUFSIZE, sizeof(Char));
Char *ptr = fbuf[buf] + off;
fbuf[0] = xcalloc(BUFSIZE, sizeof(Char));
static Char *
Char wbuf[BUFSIZE], *wp;
*wp++ = (Char)c;
*wp++ = (Char)c1;
*wp++ = (Char)c;
*wp++ = (Char)c;
Char name[4*MAXVARLEN+1], *ep, *np;
*np++ = (Char)c, c = getC(DOEXCL);
special++, *np++ = (Char)c, c = getC(DOEXCL);
*np++ = (Char)c;
*np++ = (Char)c;
*np++ = (Char)c;
*np++ = (Char)c;
*np++ = (Char)c;
*np++ = (Char)c, c = getC(DOEXCL);
*np++ = (Char)c; c = getC(DOEXCL);
*np++ = (Char)c, c = getC(DOEXCL);
*np++ = (Char)c;
*np++ = (Char)delim;
*np++ = (Char)c;
static Char *word(void);
*np++ = (Char)c;
addla(Char *cp)
static struct Hist *findev(Char *, int);
Char buf[BUFSIZE];
(sizeof(labuf) - 4) / sizeof(Char)) {
static void setexclp(Char *);
static Char lhsb[32];
static Char slhs[32];
static Char rhsb[64];
static int matchs(Char *, Char *);
static Char *subword(Char *, int, int *);
Char orhsb[sizeof(rhsb) / sizeof(Char)];
Char *cp;
if (cp > &lhsb[sizeof(lhsb) / sizeof(Char) - 2]) {
*cp++ = (Char)c;
sizeof(Char) - 2])
if (cp > &rhsb[sizeof(rhsb) / sizeof(Char) - 2]) {
*cp++ = (Char)c;
Char *tword, *otword;
static Char *
subword(Char *cp, int type, int *adid)
Char wbuf[BUFSIZE];
Char *mp, *np, *wp;
static Char *exclp = NULL;
Char *
domod(Char *cp, int type)
Char *wp, *xp;
blklen(Char **av)
Char **
blkcpy(Char **oav, Char **bv)
Char **av;
Char **
blkcat(Char **up, Char **vp)
blkfree(Char **av0)
Char **av;
Char **
saveblk(Char **v)
Char **newv, **onewv;
Char **
blkspl(Char **up, Char **vp)
Char **wp;
Char
lastchr(Char *cp)
lshift(Char **v, size_t c)
Char **u;
number(Char *cp)
Char **
copyblk(Char **v)
Char **nv;
Char *
strip(Char *cp)
Char *dp;
Char *
quote(Char *cp)
Char *dp;
udvar(Char *name)
prefix(Char *sub, Char *str)
Char **
blkend(Char **up)
blkpr(FILE *fp, Char **av)
Char *cp;
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 *signame;
Char *p_command; /* first PMAXLEN chars of command */
blkfree((Char **)Vt);
Char **v;
static Char *
splicepipe(struct command *t, Char *cp /* word after < or > */)
Char *blk[2];
Char **pv;
Char **av = blkspl(t->t_dcom, &pv[1]);
Char *cp;
static Char *splicepipe(struct command *t, Char *);
update_vars(Char *vp)
Char *pn = value(STRhistchars);
Char *cp;
doset(Char **v, struct command *t)
Char op, *p, **vecp, *vp;
Char **e = v;
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 c, op, *p, *vp;
static Char *
xset(Char *cp, Char ***vp)
Char *dp;
static Char *
operate(int op, Char *vp, Char *p)
Char opr[2], **v, *vec[5], **vecp;
opr[0] = (Char)op;
static Char *putp;
Char *
static Char numbers[15];
*putp++ = (Char)(n % 10 + '0');
getn(Char *cp)
Char *
value1(Char *var, struct varent *head)
madrof(Char *pat, struct varent *vp)
adrof1(Char *name, struct varent *v)
set(Char *var, Char *val)
Char **vec;
set1(Char *var, Char **vec, struct varent *head)
Char **oldv;
static Char *getinx(Char *, int *);
setq(Char *name, Char **vec, struct varent *p)
static void asx(Char *, int, Char *);
static struct varent *getvx(Char *, int);
unset(Char **v, struct command *t)
static Char *xset(Char *, Char ***);
static Char *operate(int, Char *, Char *);
Char *vn = value(STRhistchars);
static struct varent *madrof(Char *, struct varent *);
static void exportpath(Char **);
unset1(Char *v[], struct varent *head)
unsetv(Char *var)
setNS(Char *cp)
shift(Char **v, struct command *t)
Char *name;
exportpath(Char **val)
Char exppath[BUFSIZE];
Char **av;
Char *dst, *edst;
*dst++ = (Char) ((unsigned char) *src++);
short2str(const Char *src)
Char *
s_strcpy(Char *dst, const Char *src)
Char *sdst;
Char *
s_strncpy(Char *dst, const Char *src, size_t n)
Char *sdst;
Char *
s_strcat(Char *dst, const Char *src)
Char *
s_strncat(Char *dst, Char *src, size_t n)
Char *sdst;
Char *
s_strchr(const Char *str, int ch)
Char *
s_strrchr(const Char *str, int ch)
const Char *rstr;
s_strlen(const Char *str)
s_strcmp(const Char *str1, const Char *str2)
s_strncmp(const Char *str1, const Char *str2, size_t n)
Char *
s_strsave(const Char *s)
const Char *p;
Char *n;
Char *
s_strspl(const Char *cp, const Char *dp)
Char *ep, *d;
const Char *p, *q;
Char *
s_strend(const Char *cp)
Char *
s_strstr(const Char *s, const Char *t)
const Char *ss = s;
const Char *tt = t;
short2qstr(const Char *src)
vis_str(const Char *cp)
const Char *dp;
Char **
Char **dst, **sdst;
short2blk(Char *const *src)
Char *
static Char *sdst;
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_opendir(Char *str, glob_t *pglob)
g_lstat(Char *fn, __gl_stat_t *sb, glob_t *pglob)
g_stat(Char *fn, __gl_stat_t *sb, glob_t *pglob)
static Char *
g_strchr(const Char *str, int ch)
g_Ctoc(const Char *str, char *buf, size_t len)
qprintf(const char *str, Char *s)
Char *p;
#define M_QUOTE (Char)0x80
#define M_PROTECT (Char)0x40
#define M_MASK (Char)0xff
#define M_ASCII (Char)0x7f
#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 *, __gl_stat_t *, glob_t *);
static DIR *g_opendir(Char *, glob_t *);
static Char *g_strchr(const Char *, int);
static int g_stat(Char *, __gl_stat_t *, glob_t *);
static int glob0(const Char *, glob_t *, struct glob_limit *);
static int glob1(Char *, glob_t *, struct glob_limit *);
static int glob2(Char *, Char *, Char *, const Char *, glob_t *,
static int glob3(Char *, Char *, Char *, const Char *, const Char *,
const Char *, glob_t *, struct glob_limit *);
static int globextend(const Char *, glob_t *, struct glob_limit *);
static int globtilde(const Char **, const Char *, Char *, size_t,
static int globexp1(const Char *, glob_t *, struct glob_limit *);
static int globexp2(const Char *, const Char *, glob_t *, int *,
static int match(const Char *, const Char *, const Char *);
static void qprintf(const char *, Char *);
Char *bufnext, *bufend, patbuf[MAXPATHLEN+1];
globexp1(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
const Char* ptr = pattern;
while ((ptr = (const Char *) g_strchr(ptr, LBRACE)) != NULL)
globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv,
Char *lm, *ls;
const Char *pe, *pm, *pl;
Char patbuf[MAXPATHLEN + 1];
globtilde(const Char **qpatnext, const Char *pattern, Char *patbuf,
const Char *p;
Char *b;
Char *pend = &patbuf[patsize / sizeof(Char)];
glob0(const Char *pattern, glob_t *pglob, struct glob_limit *limit)
const Char *qpatnext;
Char *bufnext, patbuf[MAXPATHLEN+1];
glob1(Char *pattern, glob_t *pglob, struct glob_limit *limit)
Char pathbuf[MAXPATHLEN+1];
glob2(Char *pathbuf, Char *pathend, Char *pathlim, const Char *pattern,
const Char *p;
Char *q;
glob3(Char *pathbuf, Char *pathend, Char *pathlim, const Char *pattern,
const Char *restpattern, const Char *pglobstar, glob_t *pglob,
const Char *termstar = NULL;
Char *dc;
globextend(const Char *path, glob_t *pglob, struct glob_limit *limit)
const Char *p;
match(const Char *name, const Char *pat, const Char *patend)
Char c, k;
const Char *patNext, *nameNext, *nameStart, *nameEnd;
const Char *str;
str = va_arg(va, const Char *);
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)
Char *decode_result;
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)
FUN(tok,init)(const Char *ifs)
int *argc, const Char ***argv, int *cursorc, int *cursoro)
const Char *ptr;
Char *s = tok_realloc(tok->wspace,
const Char **p;
FUN(tok,str)(TYPE(Tokenizer) *tok, const Char *line, int *argc,
const Char ***argv)
Char *ifs; /* In field separator */
const 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 */