Browse Source

Fixed checking for redirection tokens

pre-master-46
Jim Monte 6 years ago
committed by Holger Vogt
parent
commit
ce5410d33f
  1. 14
      src/frontend/streams.c

14
src/frontend/streams.c

@ -47,13 +47,13 @@ wordlist *cp_redirect(wordlist *wl)
{ {
int gotinput = 0, gotoutput = 0, goterror = 0, append = 0; int gotinput = 0, gotoutput = 0, goterror = 0, append = 0;
wordlist *w; wordlist *w;
char *fname;
FILE *fp; FILE *fp;
w = wl->wl_next; /* Don't consider empty commands. */ w = wl->wl_next; /* Don't consider empty commands. */
while (w) { while (w) {
if (*w->wl_word == cp_lt) {
char *fname;
if (*w->wl_word == cp_lt && w->wl_word[1] == '\0') {
wordlist *beg = w; wordlist *beg = w;
@ -63,14 +63,14 @@ wordlist *cp_redirect(wordlist *wl)
} }
w = w->wl_next; w = w->wl_next;
if (w && *w->wl_word == cp_lt) {
if (w && *w->wl_word == cp_lt && w->wl_word[1] == '\0') {
fprintf(cp_err, "Error: `<<' redirection is not implemented.\n"); fprintf(cp_err, "Error: `<<' redirection is not implemented.\n");
goto error; goto error;
} }
if (!w) { if (!w) {
fprintf(cp_err, "Error: missing name for input.\n"); fprintf(cp_err, "Error: missing name for input.\n");
return (NULL);
return (wordlist *) NULL;
} }
fname = cp_unquote(w->wl_word); fname = cp_unquote(w->wl_word);
@ -100,7 +100,7 @@ wordlist *cp_redirect(wordlist *wl)
} }
} }
else if (*w->wl_word == cp_gt) {
else if (*w->wl_word == cp_gt && w->wl_word[1] == '\0') {
wordlist *beg = w; wordlist *beg = w;
if (gotoutput++) { if (gotoutput++) {
@ -109,7 +109,7 @@ wordlist *cp_redirect(wordlist *wl)
} }
w = w->wl_next; w = w->wl_next;
if (w && *w->wl_word == cp_gt) {
if (w && *w->wl_word == cp_gt && w->wl_word[1] == '\0') {
append++; append++;
w = w->wl_next; w = w->wl_next;
} }
@ -163,7 +163,7 @@ wordlist *cp_redirect(wordlist *wl)
else { else {
w = w->wl_next; w = w->wl_next;
} }
}
} /* end of loop over arguments */
return wl; return wl;
error: error:

Loading…
Cancel
Save