/* Copyright (c) 1979 Regents of the University of California */
register struct biltins
*bp
;
return ((struct biltins
*) 1);
for (bp
= bfunc
; dp
= bp
->bname
; bp
++) {
if (dp
[0] == cp
[0] && eq(dp
, cp
))
register struct command
*t
;
register struct biltins
*bp
;
if (lastchr(t
->t_dcom
[0]) == ':') {
if (!eq(t
->t_dcom
[0], ":") && t
->t_dcom
[1])
error("No args on labels");
bp
= isbfunc(t
->t_dcom
[0]);
/* timed builtins must go in background if output is pipe, or &'ed */
if (eq(bp
->bname
, "time"))
if ((t
->t_dflg
& FAND
) || (t
->t_dflg
& FPOU
))
if (eq(bp
->bname
, "nohup") && t
->t_dcom
[1])
i
= blklen(t
->t_dcom
) - 1;
bferr("Too few arguments");
bferr("Too many arguments");
i
= (*bp
->bfunct
)(t
->t_dcom
, t
);
/* time and nice may not do their deeds, all others guarantee too */
return (eq(bp
->bname
, "time") || eq(bp
->bname
, "nice") ? i
: 1);
register char *vv
= v
[1];
bferr("Can't from terminal");
cp
= gointr
, gointr
= 0, xfree(cp
);
signal(SIGINT
, setintr
? SIG_IGN
: SIG_DFL
);
} else if (eq((vv
= strip(vv
)), "-")) {
bferr("Can't from terminal");
register struct varent
*vp
;
vp
= adrof1(strip(p
), &aliases
);
blkpr(vp
->vec
), printf("\n");
if (eq(p
, "alias") || eq(p
, "unalias")) {
bferr("Too dangerous to alias that");
set1(strip(p
), saveblk(v
), &aliases
);
execl("/bin/login", "login", v
[1], 0);
execl("/bin/newgrp", "newgrp", v
[1], 0);
execl("/usr/bin/newgrp", "newgrp", v
[1], 0);
error("Not login shell");
if (*vv
&& eq(*vv
, "then")) {
* If expression was zero, then scan to else,
* otherwise just fall into following code.
* Simple command attached to this if.
* Left shift the node in this tree, munging it
* so we can reexecute it.
lshift(kp
->t_dcom
, vv
- kp
->t_dcom
);
* Reexecute a command, being careful not
* to redo i/o redirection, which is already set up.
register struct command
*kp
;
register struct whyle
*wp
;
* While we still can, locate any unknown ends of existing loops.
* This obscure code is the WORST result of the fact that we
for (wp
= whyles
; wp
; wp
= wp
->w_next
)
wp
->w_end
= search(ZBREAK
, 0);
search(ZGOTO
, 0, lp
= globone(v
[1]));
* Eliminate loops which were exited.
if (!*v
|| *(*v
++) != '(')
cp
= **v
== ')' ? "" : *v
++;
search(ZSWITCH
, 0, lp
= globone(cp
));
bferr("Not in while/foreach");
* Don't DEMAND parentheses here either.
set("status", putn(exp(&v
)));
bferr("Expression syntax");
register struct whyle
*nwp
;
while (*cp
&& letter(*cp
))
if (*cp
|| strlen(*v
) >= 20)
bferr("Invalid variable");
if (v
[0][0] != '(' || v
[blklen(v
) - 1][0] != ')')
bferr("Words not ()'ed");
gflag
= 0, rscan(v
, tglob
);
nwp
= (struct whyle
*) calloc(1, sizeof *nwp
);
nwp
->w_fe
= nwp
->w_fe0
= v
; gargv
= 0;
nwp
->w_fename
= savestr(cp
);
* Pre-read the loop so as to be more
* comprehensible to a terminal user.
register bool again
= whyles
!= 0 && whyles
->w_start
== lineloc
;
* Implement prereading here also, taking care not to
* evaluate the expression before the loop has been read up
bferr("Expression syntax");
register struct whyle
*nwp
= (struct whyle
*) calloc(1, sizeof (*nwp
));
/* We ain't gonna loop no more, no more! */
register int (*oldint
)();
oldint
= signal(SIGINT
, pintr
);
bferr("Not in while/foreach");
bferr("Not in while/foreach");
/* Repeating a while is simple */
if (whyles
->w_fename
== 0) {
* The foreach variable list actually has a spurious word
* ")" at the end of the w_fe list. Thus we are at the
* of the list if one word beyond this is 0.
set(whyles
->w_fename
, savestr(*whyles
->w_fe
++));
register int (*saveintr
)();
saveintr
= signal(SIGINT
, SIG_IGN
);
signal(SIGINT
, saveintr
);
register struct srch
*sp
;
for (sp
= srchn
; sp
->s_name
; sp
++)
search(type
, level
, goal
)
register char *aword
= wordbuf
;
Stype
= type
; Sgoal
= goal
;
if (intty
&& fseekp
== feobp
)
aword
[0] = 0, getword(aword
);
if (level
== 0 && type
== ZIF
)
if ((type
== ZIF
|| type
== ZELSE
) && eq(aword
, "then"))
if (type
== ZIF
|| type
== ZELSE
)
if (type
== ZSWITCH
|| type
== ZBRKSW
)
if (type
== ZSWITCH
|| type
== ZBRKSW
)
if (type
== ZGOTO
&& getword(aword
) && eq(aword
, goal
))
if (type
!= ZGOTO
&& (type
!= ZSWITCH
|| level
!= 0))
if (lastchr(aword
) != ':')
aword
[strlen(aword
) - 1] = 0;
if (type
== ZGOTO
&& eq(aword
, goal
) || type
== ZSWITCH
&& eq(aword
, "default"))
if (type
!= ZSWITCH
|| level
!= 0)
if (lastchr(aword
) == ':')
aword
[strlen(aword
) - 1] = 0;
cp
= strip(Dfix1(aword
));
if (type
== ZSWITCH
&& level
== 0)
while (c
== ' ' || c
== '\t')
if (c
== '\\' && (c
= readc(1)) == '\n')
} while ((d
|| c
!= ' ' && c
!= '\t') && c
!= '\n');
bferr("then/endif not found");
bferr("endif not found");
bferr("endsw not found");
bferr("label not found");
if (whyles
->w_end
== 0) {
whyles
->w_end
= btell() - 1;
register struct whyle
*wp
= whyles
;
register struct whyle
*nwp
= wp
->w_next
;
if (o
>= wp
->w_start
&& (wp
->w_end
== 0 || o
< wp
->w_end
))
saveintr
= signal(SIGINT
, pintr
);
gflag
= 0; rscan(v
, tglob
);
if (sep
== ' ' && *cp
&& c
== '\\') {
signal(SIGINT
, saveintr
);
blkfree(gargv
), gargv
= 0;
char *lp
= globone(v
[2]);
register char **ep
= environ
;
char *blk
[2], **oep
= ep
;
for (cp
= name
, dp
= *ep
; *cp
&& *cp
== *dp
; cp
++, dp
++)
if (*cp
!= 0 || *dp
!= '=')
blk
[0] = strspl(name
, "="); blk
[1] = 0;
environ
= blkspl(environ
, blk
);
register char *cp
= v
[1];
while (digit(*cp
) && *cp
!= '8' && *cp
!= '9')
if (*cp
|| i
< 0 || i
> 0777)