static char sccsid
[] = "@(#)main.c 4.2 %G%";
* Bell Telephone Laboratories
LOCAL BOOL beenhere
= FALSE
;
CHAR tmpout
[20] = "/tmp/sh-";
/* initialise storage allocation */
/* set names from userenv */
/* look for restricted */
/* IF c>0 ANDF any('r', *v) THEN rflag=0 FI */
IF dolc
<2 THEN flags
|= stdflg FI
/* return here for shell file execution */
/* number of positional parameters */
assnum(&pidadr
, getpid());
/* set up temp file names */
ANDF (input
=pathopen(nullstr
, profile
))>=0
THEN
exfile(rflag
); flags
&= ~ttyflg
;
IF rflag
==0 THEN flags
|= rshflg FI
/* open input file if specified */
THEN
estabf(comdiv
); input
= -1;
ELSE input
=((flags
&stdflg
) ? 0 : chkopen(cmdadr
));
ELSE
*execargs
=dolv
; /* for `ps' cmd */
/* move output to safe place */
/* decide whether interactive */
IF (flags
&intflg
) ORF ((flags
&oneflg
)==0 ANDF
gtty(output
,&statb
)==0 ANDF
gtty(input
,&statb
)==0)
THEN
dfault(&ps1nod
, (userid
?stdprompt
:supprompt
));
dfault(&ps2nod
, readmsg
);
flags
|= ttyflg
|prompt
; ignsig(KILL
);
signal(SIGTTIN, SIG_IGN);
signal(SIGTTOU, SIG_IGN);
signal(SIGTSTP, SIG_IGN);
ELSE flags
|= prof
; flags
&= ~prompt
;
IF
setjmp(errshell
) ANDF prof
THEN
close(input
); return;
loopcnt
=breakcnt
=peekc
=0; iopend
=0;
IF input
>=0 THEN
initf(input
) FI
stakchk(); /* may reduce sbrk */
IF (flags
&prompt
) ANDF standin
->fstak
==0 ANDF
!eof
ANDF
stat(mailnod
.namval
,&statb
)>=0 ANDF statb
.st_size
ANDF (statb
.st_mtime
!= mailtime
)
trapnote
=0; peekc
=readc();
execute(cmd(NL
,MTFLG
),0);
IF (flags
&prompt
) ANDF standin
->fstak
==0 ANDF eor
==NL
itos(getpid()); serial
=0;
tmpnam
=movstr(numbuf
,&tmpout
[TMPNAM
]);