summary refs log tree commit diff
path: root/src/eval.c
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2010-05-27 14:21:17 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2010-05-27 14:21:17 +0800
commitf74ae6869a7a9124c8a5cb5f3f64491d28200cc3 (patch)
treed354a116fe3bcbf9fc932076d516721796e74fc5 /src/eval.c
parent[VAR] Do not poplocalvars prematurely on regular utilities (diff)
downloaddash-f74ae6869a7a9124c8a5cb5f3f64491d28200cc3.tar.gz
dash-f74ae6869a7a9124c8a5cb5f3f64491d28200cc3.zip
[REDIR] Move null redirect checks into caller
The null redirect checks were added as an optimisation to avoid
unnecessary memory allocations.  However, we could avoid this
completely by simply making the caller avoid making a redirection
unless it is not null.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r--src/eval.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/eval.c b/src/eval.c
index 337667f..59bded9 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -224,7 +224,8 @@ evaltree(union node *n, int flags)
 			evaltree(n->nredir.n, flags & EV_TESTED);
 			status = exitstatus;
 		}
-		popredir(0);
+		if (n->nredir.redirect)
+			popredir(0);
 		goto setstatus;
 	case NCMD:
 #ifdef notyet
@@ -879,7 +880,8 @@ raise:
 	}
 
 out:
-	popredir(execcmd);
+	if (cmd->ncmd.redirect)
+		popredir(execcmd);
 	unwindlocalvars(localvar_stop);
 	if (lastarg)
 		/* dsl: I think this is intended to be used to support