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
This commit is contained in:
parent
33ba652f9b
commit
f3c8b50aa4
|
@ -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 @@ Conditional expressions are also preceded by a single dot as the first
|
|||
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.
|
||||
|
|
|
@ -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_End(void);
|
|||
void Var_Dump(GNode *);
|
||||
void Var_ExportVars(void);
|
||||
void Var_Export(char *, int);
|
||||
void Var_UnExport(char *);
|
||||
|
|
|
@ -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 @@ Parse_File(const char *name, int fd)
|
|||
continue;
|
||||
Var_Export(cp, 1);
|
||||
continue;
|
||||
} else if (strncmp(cp, "unexport", 8) == 0) {
|
||||
Var_UnExport(cp);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ SUBFILES= \
|
|||
posix \
|
||||
qequals \
|
||||
ternary \
|
||||
unexport \
|
||||
unexport-env \
|
||||
varcmd
|
||||
|
||||
all: ${SUBFILES}
|
||||
|
|
Loading…
Reference in New Issue