/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
*
* UNIX shell
*
*/
#include "defs.h"
#include <errno.h>
#include "sym.h"
#include "hash.h"
void execprint(unsigned char **);
/* ======== command execution ======== */
/*VARARGS3*/
int
{
/*
* `stakbot' is preserved by this routine
*/
struct trenod *t;
sigchk();
if (!errorflg)
int treeflgs;
unsigned char **com;
int type;
short pos;
switch (type)
{
case TFND:
{
exitval = 0;
/*
* If function of same name is previously
* defined, it will no longer be used.
*/
freefunc(n);
} else {
n->namval = 0;
}
/*
* If function is defined within function,
* we don't want to free it along with the
* free of the defining function. If we are
* in a loop, fndnod may be reused, so it
* should never be freed.
*/
f->fndref++;
/*
* We hang a fndnod on the namenv so that
* ref cnt(fndref) can be increased while
* running in the function.
*/
n->namenv = (unsigned char *)f;
break;
}
case TCOM:
{
short cmdhash;
short comtype;
exitval = 0;
gchain = 0;
if (argn != 0)
}
{
/* print command if execpr */
{
if (pos == 1)
else if (pos == 2)
else
break;
}
else if (comtype == PATH_COMMAND)
{
pos = -1;
}
{
}
freejobs();
break;
}
{
struct fndnod *f;
short index;
/* just in case */
if (f == NULL)
break;
/* save current positional parameters */
f->fndref++;
funcnt++;
execbrk = 0;
funcnt--;
/*
* n->namenv may have been
* pointing different func.
* Therefore, we can't use
* freefunc(n).
*/
break;
}
}
else if (t->treio == 0)
{
chktrap();
break;
}
}
case TFORK:
{
int monitor = 0;
int linked = 0;
exitval = 0;
{
{
== (monitorflg|jcflg));
if (monitor) {
int savefd;
unsigned char *savebot;
prcmd(t);
} else
}
linked = 1;
}
{
/*
* FORKLIM is the max period between forks -
* power of 2 usually. Currently shell tries
* after 2,4,8,16, and 32 seconds and then quits
*/
{
switch (errno)
{
case ENOMEM:
deallocjob();
break;
default:
deallocjob();
break;
}
deallocjob();
break;
}
sigchk();
}
if (parent) {
if (monitor)
freejobs();
}
chktrap();
break;
}
}
/*
* Forked process: assume it is not a subshell for
* now. If it is, the presence of a left parenthesis
* will trigger the jcoff flag to be turned off.
* When jcoff is turned on, monitoring is not going on
* and waitpid will not look for WUNTRACED.
*/
fiotemp = 0;
if (linked == 1) {
xflags |= XEC_LINKED;
} else if (!(xflags & XEC_LINKED))
iotemp = 0;
#ifdef ACCT
suspacct();
#endif
settmp();
oldsigs();
/*
* pipe in or out
*/
{
}
{
}
/*
* io redirection
*/
{
eflag = 0;
rmtemp(0);
clearjobs();
}
done(0);
}
case TPAR:
/* Forked process is subshell: may want job control */
clearjobs();
done(0);
case TFIL:
{
else
}
break;
case TLST:
/* Update errorflg if set -e is invoked in the sub-sh*/
break;
case TAND:
case TORF:
{
int xval;
break;
}
case TFOR:
{
unsigned char **args;
{
}
else
{
gchain = 0;
}
loopcnt++;
{
if (breakcnt < 0)
}
if (breakcnt > 0)
loopcnt--;
if(argsav)
}
break;
case TWH:
case TUN:
{
int i = 0;
loopcnt++;
{
if (breakcnt < 0)
}
if (breakcnt > 0)
loopcnt--;
exitval = i;
}
break;
case TIF:
else
exitval = 0; /* force zero exit for if-then-fi */
break;
case TSW:
{
while (regp)
{
while (rex)
{
unsigned char *s;
{
regp = 0;
break;
}
else
}
if (regp)
}
}
break;
}
exitset();
}
sigchk();
return(exitval);
}
void
execexp(unsigned char *s, int f)
{
if (s)
{
estabf(s);
}
else if (f >= 0)
initf(f);
pop();
}
void
{
int argn = 0;
unsigned char *s;
{
blank();
}
newline();
}