Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Add .unexport - the exact opposite of .export
details: https://anonhg.NetBSD.org/src/rev/7c98a6b63919
branches: trunk
changeset: 749145:7c98a6b63919
user: sjg <sjg%NetBSD.org@localhost>
date: Thu Nov 19 00:30:24 2009 +0000
description:
Add .unexport - the exact opposite of .export
and .unexport-env which unexport's all previously .export'd globals
as well as clearing environ[].
Allow's sys.mk near total controll.
Reviewed by: apb
diffstat:
usr.bin/make/make.1 | 44 ++++++++++++++++++++++++++++++++++++---
usr.bin/make/nonints.h | 3 +-
usr.bin/make/parse.c | 9 +++++--
usr.bin/make/unit-tests/Makefile | 4 ++-
4 files changed, 51 insertions(+), 9 deletions(-)
diffs (142 lines):
diff -r 2129f0dc00e6 -r 7c98a6b63919 usr.bin/make/make.1
--- a/usr.bin/make/make.1 Wed Nov 18 23:13:09 2009 +0000
+++ b/usr.bin/make/make.1 Thu Nov 19 00:30:24 2009 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.164 2009/10/15 02:27:44 joerg Exp $
+.\" $NetBSD: make.1,v 1.165 2009/11/19 00:30:24 sjg Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" from: @(#)make.1 8.4 (Berkeley) 3/19/94
.\"
-.Dd October 1, 2009
+.Dd November 15, 2009
.Dt MAKE 1
.Os
.Sh NAME
@@ -1274,17 +1274,53 @@
character of a line.
The possible conditionals are as follows:
.Bl -tag -width Ds
-.It Ic .export Ar variable
+.It Ic .export Ar variable ...
Export the specified global variable.
-If no variable is provided, all globals are exported
+If no variable list is provided, all globals are exported
except for internal variables (those that start with
.Ql \&. ) .
This is not affected by the
.Fl X
flag, so should be used with caution.
+.Pp
Appending a variable name to
.Va .MAKE.EXPORTED
is equivalent to exporting a variable.
+.It Ic .unexport Ar variable ...
+The opposite of
+.Ql .export .
+The specified global
+.Va variable
+will be removed from
+.Va .MAKE.EXPORTED .
+If no variable list is provided, all globals are unexported,
+and
+.Va .MAKE.EXPORTED
+deleted.
+.It Ic .unexport-env
+Unexport all globals previously exported and
+clear the environment inherited from the parent.
+This operation will cause a memory leak of the original environment,
+so should be used sparingly. Testing for
+.Va .MAKE.LEVEL
+being 0, would make sense.
+Also note that any variables which originated in the parent environment
+should be explicitly preserved if desired.
+For example:
+.Bd -literal -offset indent
+.Li .if ${.MAKE.LEVEL} == 0
+PATH := ${PATH}
+.Li .unexport-env
+.Li .export PATH
+.Li .endif
+.Pp
+.Ed
+Would result in an environment containing only
+.Ql Ev PATH ,
+which is the minimal useful environment.
+Actually
+.Ql Ev .MAKE.LEVEL
+will also be pushed into the new environment.
.It Ic .undef Ar variable
Un-define the specified global variable.
Only global variables may be un-defined.
diff -r 2129f0dc00e6 -r 7c98a6b63919 usr.bin/make/nonints.h
--- a/usr.bin/make/nonints.h Wed Nov 18 23:13:09 2009 +0000
+++ b/usr.bin/make/nonints.h Thu Nov 19 00:30:24 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nonints.h,v 1.56 2009/01/28 21:38:13 dsl Exp $ */
+/* $NetBSD: nonints.h,v 1.57 2009/11/19 00:30:24 sjg Exp $ */
/*-
* Copyright (c) 1988, 1989, 1990, 1993
@@ -193,3 +193,4 @@
void Var_Dump(GNode *);
void Var_ExportVars(void);
void Var_Export(char *, int);
+void Var_UnExport(char *);
diff -r 2129f0dc00e6 -r 7c98a6b63919 usr.bin/make/parse.c
--- a/usr.bin/make/parse.c Wed Nov 18 23:13:09 2009 +0000
+++ b/usr.bin/make/parse.c Thu Nov 19 00:30:24 2009 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: parse.c,v 1.159 2009/11/06 20:20:56 dsl Exp $ */
+/* $NetBSD: parse.c,v 1.160 2009/11/19 00:30:25 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.159 2009/11/06 20:20:56 dsl Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.160 2009/11/19 00:30:25 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: parse.c,v 1.159 2009/11/06 20:20:56 dsl Exp $");
+__RCSID("$NetBSD: parse.c,v 1.160 2009/11/19 00:30:25 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -2510,6 +2510,9 @@
continue;
Var_Export(cp, 1);
continue;
+ } else if (strncmp(cp, "unexport", 8) == 0) {
+ Var_UnExport(cp);
+ continue;
}
}
diff -r 2129f0dc00e6 -r 7c98a6b63919 usr.bin/make/unit-tests/Makefile
--- a/usr.bin/make/unit-tests/Makefile Wed Nov 18 23:13:09 2009 +0000
+++ b/usr.bin/make/unit-tests/Makefile Thu Nov 19 00:30:24 2009 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.24 2009/10/07 16:40:30 sjg Exp $
+# $NetBSD: Makefile,v 1.25 2009/11/19 00:30:25 sjg Exp $
#
# Unit tests for make(1)
# The main targets are:
@@ -34,6 +34,8 @@
posix \
qequals \
ternary \
+ unexport \
+ unexport-env \
varcmd
all: ${SUBFILES}
Home |
Main Index |
Thread Index |
Old Index