Module Name: src Committed By: sjg Date: Wed Apr 21 04:25:28 UTC 2010
Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: export-all test.exp Log Message: If we do .export (all) and have any variables that involve :sh we will hit an error (var is recursive) while trying to evaluate that. Fix, and add a unit test for this. To generate a diff of this commit: cvs rdiff -u -r1.157 -r1.158 src/usr.bin/make/var.c cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/export-all cvs rdiff -u -r1.31 -r1.32 src/usr.bin/make/unit-tests/test.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.157 src/usr.bin/make/var.c:1.158 --- src/usr.bin/make/var.c:1.157 Tue Apr 20 17:48:16 2010 +++ src/usr.bin/make/var.c Wed Apr 21 04:25:27 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.157 2010/04/20 17:48:16 sjg Exp $ */ +/* $NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.157 2010/04/20 17:48:16 sjg Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.157 2010/04/20 17:48:16 sjg Exp $"); +__RCSID("$NetBSD: var.c,v 1.158 2010/04/21 04:25:27 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -591,6 +591,13 @@ v->flags |= (VAR_EXPORTED|VAR_REEXPORT); return 1; } + if (v->flags & VAR_IN_USE) { + /* + * We recursed while exporting in a child. + * This isn't going to end well, just skip it. + */ + return 0; + } n = snprintf(tmp, sizeof(tmp), "${%s}", name); if (n < (int)sizeof(tmp)) { val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); Index: src/usr.bin/make/unit-tests/export-all diff -u src/usr.bin/make/unit-tests/export-all:1.1 src/usr.bin/make/unit-tests/export-all:1.2 --- src/usr.bin/make/unit-tests/export-all:1.1 Fri Oct 5 15:27:46 2007 +++ src/usr.bin/make/unit-tests/export-all Wed Apr 21 04:25:28 2010 @@ -1,8 +1,20 @@ -# $Id: export-all,v 1.1 2007/10/05 15:27:46 sjg Exp $ +# $Id: export-all,v 1.2 2010/04/21 04:25:28 sjg Exp $ UT_OK=good UT_F=fine +# the old way to do :tA +M_tAbad = C,.*,cd & \&\& 'pwd',:sh +# the new +M_tA = tA + +here := ${.PARSEDIR} + +# this will cause trouble (recursing if we let it) +UT_BADDIR = ${${here}/../${here:T}:L:${M_tAbad}:T} +# this will be ok +UT_OKDIR = ${${here}/../${here:T}:L:${M_tA}:T} + .export .include "export" Index: src/usr.bin/make/unit-tests/test.exp diff -u src/usr.bin/make/unit-tests/test.exp:1.31 src/usr.bin/make/unit-tests/test.exp:1.32 --- src/usr.bin/make/unit-tests/test.exp:1.31 Thu Apr 8 17:41:29 2010 +++ src/usr.bin/make/unit-tests/test.exp Wed Apr 21 04:25:28 2010 @@ -33,12 +33,14 @@ UT_TEST=export UT_ZOO=hoopie UT_ALL=even this gets exported +UT_BADDIR=unit-tests UT_DOLLAR=This is $UT_FU UT_F=fine UT_FOO=foobar is fubar UT_FU=fubar UT_NO=all UT_OK=good +UT_OKDIR=unit-tests UT_TEST=export-all UT_ZOO=hoopie At first, I am