Patch from vodz to make ash cope with leading redirections

(i.e. '2>/dev/null ls rubbish') will now work.
This commit is contained in:
Eric Andersen 2001-09-06 17:35:20 +00:00
parent 1644db9a2b
commit 88cec25e99
3 changed files with 21 additions and 6 deletions

View File

@ -13,6 +13,7 @@
* Vladimir Oleynik, Manuel Novoa III, Aaron Lehmann * Vladimir Oleynik, Manuel Novoa III, Aaron Lehmann
-- a whole bunch of ash size optimizations -- a whole bunch of ash size optimizations
-- Fix for ash leading redirections (i.e. '2>/dev/null ls rubbish')
* Rodney Brown <RDBrown@mira.net> * Rodney Brown <RDBrown@mira.net>
-- Optimized gzip.c, shrinking it be ~1.5k -- Optimized gzip.c, shrinking it be ~1.5k
* Matt Kraai * Matt Kraai
@ -20,8 +21,8 @@
-- Fix `-/bin/sh' invocation (closes: #1209). -- Fix `-/bin/sh' invocation (closes: #1209).
-- Fix ash exec (noted by Arne Bernin). -- Fix ash exec (noted by Arne Bernin).
* Magick * Magick
-- maked init run inittab command's in inittab order ( -- made init run inittab command's in the order they show up
(i.e. FIFO instead of LIFO). in the inittab file (FIFO instead of LIFO).
-Erik Andersen, --not yet released-- -Erik Andersen, --not yet released--

11
ash.c
View File

@ -9857,6 +9857,14 @@ command() {
n1 = NULL; n1 = NULL;
rpp = &redir; rpp = &redir;
/* Check for redirection which may precede command */
while (readtoken() == TREDIR) {
*rpp = n2 = redirnode;
rpp = &n2->nfile.next;
parsefname();
}
tokpushback++;
switch (readtoken()) { switch (readtoken()) {
case TIF: case TIF:
n1 = (union node *)stalloc(sizeof (struct nif)); n1 = (union node *)stalloc(sizeof (struct nif));
@ -10026,7 +10034,6 @@ TRACE(("expecting DO got %s %s\n", tokname(got), got == TWORD ? wordtext : ""));
if (!redir) if (!redir)
synexpect(-1); synexpect(-1);
case TWORD: case TWORD:
case TREDIR:
tokpushback++; tokpushback++;
n1 = simplecmd(); n1 = simplecmd();
return n1; return n1;
@ -12673,7 +12680,7 @@ findvar(struct var **vpp, const char *name)
/* /*
* Copyright (c) 1999 Herbert Xu <herbert@debian.org> * Copyright (c) 1999 Herbert Xu <herbert@debian.org>
* This file contains code for the times builtin. * This file contains code for the times builtin.
* $Id: ash.c,v 1.22 2001/08/12 17:32:56 mjn3 Exp $ * $Id: ash.c,v 1.23 2001/09/06 17:35:20 andersen Exp $
*/ */
static int timescmd (int argc, char **argv) static int timescmd (int argc, char **argv)
{ {

View File

@ -9857,6 +9857,14 @@ command() {
n1 = NULL; n1 = NULL;
rpp = &redir; rpp = &redir;
/* Check for redirection which may precede command */
while (readtoken() == TREDIR) {
*rpp = n2 = redirnode;
rpp = &n2->nfile.next;
parsefname();
}
tokpushback++;
switch (readtoken()) { switch (readtoken()) {
case TIF: case TIF:
n1 = (union node *)stalloc(sizeof (struct nif)); n1 = (union node *)stalloc(sizeof (struct nif));
@ -10026,7 +10034,6 @@ TRACE(("expecting DO got %s %s\n", tokname(got), got == TWORD ? wordtext : ""));
if (!redir) if (!redir)
synexpect(-1); synexpect(-1);
case TWORD: case TWORD:
case TREDIR:
tokpushback++; tokpushback++;
n1 = simplecmd(); n1 = simplecmd();
return n1; return n1;
@ -12673,7 +12680,7 @@ findvar(struct var **vpp, const char *name)
/* /*
* Copyright (c) 1999 Herbert Xu <herbert@debian.org> * Copyright (c) 1999 Herbert Xu <herbert@debian.org>
* This file contains code for the times builtin. * This file contains code for the times builtin.
* $Id: ash.c,v 1.22 2001/08/12 17:32:56 mjn3 Exp $ * $Id: ash.c,v 1.23 2001/09/06 17:35:20 andersen Exp $
*/ */
static int timescmd (int argc, char **argv) static int timescmd (int argc, char **argv)
{ {