static char sccsid
[] = "@(#)mysys.c 4.2 (Berkeley) %G%";
* This routine edits the PATH environment variable so that
* special commands that learners may need will be found.
* EXINIT is modified so that the editor will always prompt,
* will not print \r's, and will be usable with open mode.
char path
[BUFSIZ
], exinit
[BUFSIZ
];
sprintf(path
, "PATH=%s/bin:/usr/cc/bin:/usr/ucb/bin:", direct
);
sprintf(exinit
, "EXINIT=set prompt noopt open");
for (p
=environ
,i
=3; *p
!= 0 && i
< EMAX
; p
++,i
++) {
for (p
=environ
,i
=2; *p
!= 0 && i
< EMAX
; p
++,i
++) {
if (**p
!= 'P' && **p
!= 'E')
if (strncmp(*p
, "PATH=", 5) == 0)
sprintf(path
, "PATH=%s/bin:%s", direct
, &envp
[i
--][5]);
else if (strncmp(*p
, "EXINIT=", 7) == 0)
sprintf(exinit
, "%s|set prompt noopt open", envp
[i
--]);
else if (strncmp(*p
, "PS1=", 4) == 0);
strcpy(envp
[2], "PS1=% ");
envp
[0] = malloc(strlen(path
) + 1);
envp
[1] = malloc(strlen(exinit
) + 1);
/* like "system" but rips off "mv", etc.*/
/* also tries to guess if can get away with exec cmd */
type
= EASY
; /* we hope */
for (t
= s
; *t
&& type
!= HARD
; t
++) {
if ((strcmp(t
, "mv") == 0)||
(strcmp(t
, "ls") == 0) ) {
/* sprintf(b, "/usr/ucb/bin/%s", t);
sprintf(b, "/usr/ucb/%s", t);
sprintf(b, "/bin/%s", t);
sprintf(b, "/usr/bin/%s", t);
fprintf(stderr
, "Mysys: execv failed on %s\n", np
);
* same as library version, except that resets
* default handling of signals in child, so that
* user gets the behavior he expects.
register int (*istat
)(), (*qstat
)();
istat
= signal(SIGINT
, SIG_IGN
);
qstat
= signal(SIGQUIT
, SIG_IGN
);
if ((pid
= fork()) == 0) {
signal(SIGQUIT
, SIG_DFL
);
execl("/bin/csh", "csh", "-cf", s
, 0);
while ((w
= wait(&status
)) != pid
&& w
!= -1)
while (*s
!= 0 && *s
!=' '&& *s
!= '\t')
while (*s
== ' ' || *s
== '\t')