35 #ifdef HAVE_SYS_WAIT_H 87 char *
s, *singlec =
"<>;&";
91 for (s = singlec; *s; s++)
118 pwlist(wlist,
"Initial parse");
124 pwlist(wlist,
"After history substitution");
128 (void) putc(
'\n', stdout);
132 if (!
string && *wlist->
wl_word)
136 pwlist(wlist,
"After alias substitution");
152 fprintf(
cp_err,
"%s : [ ", name);
153 for (wl = wlist; wl; wl = wl->
wl_next)
171 if (wlist &&
eq(wlist->wl_word,
"-n")) {
177 char *
t =
copy(wlist->wl_word);
183 wlist = wlist->wl_next;
201 bool gotinput =
false, gotoutput =
false, goterror =
false;
202 bool app =
false, erralso =
false;
216 "Error: ambiguous input redirect.\n");
223 "Error: missing name for input.\n");
232 tmpfp = fopen(t,
"r");
243 fprintf(
cp_err,
"Input file is %s...\n",
258 "Error: ambiguous output redirect.\n");
265 "Error: missing name for output.\n");
273 "Error: missing name for output.\n");
281 "Error: ambiguous error redirect.\n");
288 "Error: missing name for output.\n");
295 fprintf(stderr,
"Error: %s: file exists\n", s);
300 tmpfp = fopen(s,
"a");
302 tmpfp = fopen(s,
"w+");
314 fprintf(
cp_err,
"Output file is %s... %s\n",
315 w->
wl_word, app ?
"(append)" :
"");
355 (void) fclose(
cp_in);
395 char *com, *shell =
NULL;
398 static RETSIGTYPE (*svint)( ), (*svquit)( ), (*svtstp)( );
416 (void) execl(shell, shell, 0);
421 (void) execl(
"/bin/sh",
"sh",
"-c", com, 0);
426 svint = signal(SIGINT, SIG_DFL);
427 svquit = signal(SIGQUIT, SIG_DFL);
428 svtstp = signal(SIGTSTP, SIG_DFL);
432 }
while ((r != pid) && pid != -1);
433 (void) signal(SIGINT, svint);
434 (void) signal(SIGQUIT, svquit);
435 (void) signal(SIGTSTP, svtstp);
457 (void) dup2(fileno(
cp_in), fileno(stdin));
459 (void) dup2(fileno(
cp_out), fileno(stdout));
461 (void) dup2(fileno(
cp_err), fileno(stderr));
475 fprintf(
cp_err,
"Error: unixcom not set.\n");
482 fprintf(
cp_err,
"Error: no PATH in environment.\n");
506 pw = getpwuid(getuid());
508 fprintf(
cp_err,
"Can't get your password entry\n");
515 if (s =
getcwd(localbuf,
sizeof(localbuf))) {
520 fprintf(
cp_err,
"Can't get current working directory.\n");
536 if (s && s[1] ==
':') {
538 sprintf(buf,
"%c:", *s);
544 if (*s && chdir(s) == -1)
562 fprintf(
cp_err,
"Error: 'chdir' not available.\n");
580 s1 =
copy(wl->wl_next->wl_word);
582 s2 =
copy(wl->wl_next->wl_next->wl_word);
static char buf[MAXPROMPT]
void cp_redirect(wordlist **list)
int bzero(char *ptr, int num)
char * getcwd(char *buf, int size)
struct wordlist * wl_prev
void com_rehash(wordlist *wl)
void com_chdir(wordlist *wl)
int access(char *pth, int m)
wordlist * cp_parse(char *string)
void com_strcmp(wordlist *wl)
struct wordlist * wl_next
void ShowPrompt(char *str)
void com_shell(wordlist *wl)