From f295db8fbd4fa65c88b16669ed8829995bba7d53 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Thu, 6 Sep 2001 17:39:23 +0000 Subject: [PATCH] Patch from vodz for ash leading redirections (i.e. '2>/dev/null ls rubbish') --- busybox/ash.c | 11 +++++++++-- busybox/shell/ash.c | 11 +++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/busybox/ash.c b/busybox/ash.c index 914458451..f84fabb8b 100644 --- a/busybox/ash.c +++ b/busybox/ash.c @@ -9706,7 +9706,6 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); if (!redir) synexpect(-1); case TWORD: - case TREDIR: tokpushback++; n1 = simplecmd(); return n1; @@ -9751,6 +9750,14 @@ simplecmd() { redir = NULL; rpp = &redir; + /* Check for redirection which may precede command */ + while (readtoken() == TREDIR) { + *rpp = n2 = redirnode; + rpp = &n2->nfile.next; + parsefname(); + } + tokpushback++; + checkalias = 2; for (;;) { switch (readtoken()) { @@ -12785,7 +12792,7 @@ findvar(struct var **vpp, const char *name) /* * Copyright (c) 1999 Herbert Xu * This file contains code for the times builtin. - * $Id: ash.c,v 1.17.2.1 2001/08/10 18:22:14 andersen Exp $ + * $Id: ash.c,v 1.17.2.2 2001/09/06 17:39:23 andersen Exp $ */ static int timescmd (int argc, char **argv) { diff --git a/busybox/shell/ash.c b/busybox/shell/ash.c index 914458451..f84fabb8b 100644 --- a/busybox/shell/ash.c +++ b/busybox/shell/ash.c @@ -9706,7 +9706,6 @@ TRACE(("expecting DO got %s %s\n", tokname[got], got == TWORD ? wordtext : "")); if (!redir) synexpect(-1); case TWORD: - case TREDIR: tokpushback++; n1 = simplecmd(); return n1; @@ -9751,6 +9750,14 @@ simplecmd() { redir = NULL; rpp = &redir; + /* Check for redirection which may precede command */ + while (readtoken() == TREDIR) { + *rpp = n2 = redirnode; + rpp = &n2->nfile.next; + parsefname(); + } + tokpushback++; + checkalias = 2; for (;;) { switch (readtoken()) { @@ -12785,7 +12792,7 @@ findvar(struct var **vpp, const char *name) /* * Copyright (c) 1999 Herbert Xu * This file contains code for the times builtin. - * $Id: ash.c,v 1.17.2.1 2001/08/10 18:22:14 andersen Exp $ + * $Id: ash.c,v 1.17.2.2 2001/09/06 17:39:23 andersen Exp $ */ static int timescmd (int argc, char **argv) { -- 2.25.1