Module Name: src Committed By: kre Date: Fri May 13 10:32:52 UTC 2016
Modified Files: src/bin/sh: eval.c Log Message: More fallout from the fix for PR bin/48875 - this one found just by code reading, rather than any actual real use case failing. With this script f() { echo hello $1 } exec 3>&1 echo $( for i in a b c do echo @$i f >&3 done >/tmp/foo ) echo foo= $(cat /tmp/foo) what should be output is hello hello hello foo= @a @b @c but since the (my) 48875 fix the other day, we've been getting hello @b hello @c hello foo= @a This fixes that. I think (hope) this is the last of these fixes... To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 src/bin/sh/eval.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.126 src/bin/sh/eval.c:1.127 --- src/bin/sh/eval.c:1.126 Tue May 10 15:14:30 2016 +++ src/bin/sh/eval.c Fri May 13 10:32:52 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.126 2016/05/10 15:14:30 kre Exp $ */ +/* $NetBSD: eval.c,v 1.127 2016/05/13 10:32:52 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.126 2016/05/10 15:14:30 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.127 2016/05/13 10:32:52 kre Exp $"); #endif #endif /* not lint */ @@ -413,8 +413,13 @@ evalfor(union node *n, int flags) loopnest++; for (sp = arglist.list ; sp ; sp = sp->next) { + int f = flags & (EV_TESTED | EV_MORE); + + if (sp->next) + f |= EV_MORE; + setvar(n->nfor.var, sp->text, 0); - evaltree(n->nfor.body, flags & (EV_TESTED | EV_MORE)); + evaltree(n->nfor.body, f); status = exitstatus; if (nflag) break;