/***********************************************************************
* *
* This software is part of the ast package *
* Copyright (c) 1982-2011 AT&T Intellectual Property *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by AT&T Intellectual Property *
* *
* A copy of the License is available at *
* (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) *
* *
* Information and Software Systems Research *
* AT&T Research *
* Florham Park NJ *
* *
* David Korn <dgk@research.att.com> *
* *
***********************************************************************/
#pragma prototyped
/*
* UNIX shell
*
* S. R. Bourne
* Rewritten By David Korn
* AT&T Labs
*
*/
/*
*/
#include <ast.h>
#include <sfio.h>
#include <stak.h>
#include <ls.h>
#include <fcin.h>
#include "defs.h"
#include "variables.h"
#include "path.h"
#include "io.h"
#include "jobs.h"
#include "shlex.h"
#include "shnodes.h"
#include "history.h"
#include "timeout.h"
#ifdef _hdr_nc
# include <nc.h>
#endif /* _hdr_nc */
/* These routines are referenced by this module */
#if defined(_lib_fork) && !defined(_NEXT_SOURCE)
static void fixargs(char**,int);
#else
# define fixargs(a,b)
#endif
#ifndef environ
extern char **environ;
#endif
static char beenhere = 0;
#ifdef _lib_sigvec
{
{
}
}
#endif /* _lib_sigvec */
#ifdef _lib_fts_notify
# include <fts.h>
/* check for interrupts during tree walks */
{
{
return(-1);
}
return(0);
}
#endif /* _lib_fts_notify */
#ifdef PATH_BFPATH
#else
#endif
/*
* search for file and exfile() it if it exists
* 1 returned if file found, 0 otherwise
*/
{
char* oid;
char* nid;
int fd;
{
return 0;
}
return 1;
}
#ifdef S_ISSOCK
#else
#define REMOTE(m) !(m)
#endif
{
register char *name;
register int fdin;
char *command;
#ifdef _lib_sigvec
/* This is to clear mask that may be left on by rlogin */
#endif /* _lib_sigvec */
#ifdef _hdr_nc
#endif /* _hdr_nc */
#ifdef _lib_fts_notify
#endif /* _lib_fts_notify */
{
/* begin script execution here */
sh_reinit((char**)0);
}
/* set pidname '$$' */
#if SHOPT_BRACEPAT
#endif
if((beenhere++)==0)
{
/* decide whether shell is interactive */
{
}
#if SHOPT_REMOTE
#endif
))
{
#ifdef SIGXCPU
#endif /* SIGXCPU */
#ifdef SIGXFSZ
#endif /* SIGXFSZ */
}
{
/* system profile */
{
}
}
/* make sure PWD is set up correctly */
if(!sh_isoption(SH_NOEXEC))
{
{
#if SHOPT_BASH
{
#if SHOPT_SYSRC
#endif
}
else
#endif
{
#if SHOPT_SYSRC
#endif
if(name)
{
}
}
}
}
if(rshflag)
/* open input file if specified */
{
}
else
{
if(sh_isoption(SH_SFLAG))
fdin = 0;
else
{
char *sp;
/* open stream should have been passed into shell */
{
#if !_WINIX
char *cp;
int type;
#endif
#if !_WINIX
/*
* try to undo effect of solaris 2.5+
* change for argv for setuid scripts
*/
if(((type = sh_type(cp = av[0])) & SH_TYPE_SH) && (!(name = nv_getval(L_ARGNOD)) || !((type = sh_type(cp = name)) & SH_TYPE_SH)))
{
/* exec to change $0 for ps */
/* exec fails */
}
#endif
}
else
{
int isdir = 0;
{
isdir = 1;
fdin = -1;
}
else
sp = 0;
{
#ifdef PATH_BFPATH
#else
#endif
if(sp)
{
}
}
if(fdin<0)
{
if(isdir)
/* try sh -c 'name "$@"' */
goto shell_c;
}
if(fdin==0)
}
}
#if SHOPT_ACCT
sh_accinit();
if(fdin != 0)
#endif /* SHOPT_ACCT */
}
}
else
{
}
/* NOTREACHED */
return(0);
}
/*
* iop is not null when the input is a string
* fdin is the input file descriptor
*/
{
Shnode_t *t;
/* open input stream */
if(!iop)
{
if(fno > 0)
{
int r;
{
VALIDATE_FD(shp, r);
fno = r;
}
}
else
}
else
fno = -1;
if(sh_isstate(SH_INTERACTIVE))
{
sh_sigdone();
if(sh_histinit((void*)shp))
}
else
{
if(!sh_isstate(SH_PROFILE))
{
}
}
states = sh_getstate();
if(jmpval)
{
/* check for return from profile or env file */
{
goto done;
}
if(!sh_isoption(SH_INTERACTIVE) || sh_isstate(SH_FORKED) || (jmpval > SH_JMPERREXIT && job_close(shp) >=0))
{
goto done;
}
/* skip over remaining input */
{
while(fcget()>0);
fcclose();
}
/* make sure that we own the terminal */
#ifdef SIGTSTP
#endif /* SIGTSTP */
}
/* error return here */
goto eof_or_error;
/* command loop */
while(1)
{
exitset();
if(sh_isoption(SH_VERBOSE))
/* -eim flags don't apply to profiles */
if(sh_isstate(SH_PROFILE))
{
}
{
register char *mail;
#ifdef JOBS
if(sh_isoption(SH_MONITOR))
{
}
#endif /* JOBS */
{
{
}
}
/* sets timeout for command entry */
#if SHOPT_TIMEOUT
#endif /* SHOPT_TIMEOUT */
{
#ifdef DEBUG
#endif
}
}
errno = 0;
{
{
{
continue;
}
continue;
}
{
continue;
}
goto done;
}
{
}
if(sh_isoption(SH_HISTORY))
shp->readscript = 0;
if(t)
{
/* The last command may not have to fork */
{
}
{
goto done;
}
/* This is for sh -t */
tdone++;
}
}
done:
if(sh_isstate(SH_INTERACTIVE))
{
}
if(jmpval == SH_JMPSCRIPT)
else if(jmpval == SH_JMPEXIT)
if(fno>0)
}
/* prints out messages if files in list have been modified since last call */
{
register char save;
return;
do
{
/* skip to : or end of string saving first '?' */
*sp = 0;
/* change '?' to end-of-string */
if(qp)
*qp = 0;
do
{
/* see if time has been modified since last checked
* and the access time <= the modification time
*/
{
/* check for directory */
{
/* generate list of directory entries */
}
else
{
/*
* If the file has shrunk,
* or if the size is zero
* then don't print anything
*/
{
/* save and restore $_ */
}
break;
}
}
if(arglist)
{
}
else
cp = 0;
}
while(cp);
if(qp)
*qp = '?';
}
while(save);
}
#if defined(_hdr_execargs) && defined(pdp11)
# include <execargs.h>
#endif
#if defined(_lib_pstat) && defined(_sys_pstat)
#endif
#if defined(_lib_fork) && !defined(_NEXT_SOURCE)
/*
* fix up command line for ps command
* mode is 0 for initialization
*/
{
#if EXECARGS
#else
static char *buff;
static int command_len;
register char *cp;
# ifdef PSTAT
if(mode==0)
{
struct pst_static st;
return;
return;
}
# else
if(mode==0)
{
{
{
if(command_len > CMD_LENGTH)
{
break;
}
}
}
command_len -= 1;
return;
}
# endif /* PSTAT */
if(command_len==0)
return;
{
}
# ifdef PSTAT
# endif /* PSTAT */
#endif /* EXECARGS */
}
#endif /* _lib_fork */