make(1): error out on misspelled .unexport-env
This commit is contained in:
parent
dc6cc25fbe
commit
2997f3b2f1
@ -1,6 +1,8 @@
|
||||
make: "directive-unexport-env.mk" line 15: Unknown directive "unexport-environment"
|
||||
Global:UT_EXPORTED = value
|
||||
Global:UT_UNEXPORTED = value
|
||||
Global:.MAKE.EXPORTED = UT_EXPORTED
|
||||
make: "directive-unexport-env.mk" line 21: The directive .unexport-env does not take arguments
|
||||
Var_Parse: ${.MAKE.EXPORTED:O:u} with VARE_WANTRES
|
||||
Applying ${.MAKE.EXPORTED:O} to "UT_EXPORTED" (VARE_WANTRES, none, none)
|
||||
Result of ${.MAKE.EXPORTED:O} is "UT_EXPORTED" (VARE_WANTRES, none, none)
|
||||
@ -10,4 +12,6 @@ Unexporting "UT_EXPORTED"
|
||||
Global:delete .MAKE.EXPORTED
|
||||
Global:.MAKEFLAGS = -r -k -d v -d
|
||||
Global:.MAKEFLAGS = -r -k -d v -d 0
|
||||
exit status 0
|
||||
make: Fatal errors encountered -- cannot continue
|
||||
make: stopped in unit-tests
|
||||
exit status 1
|
||||
|
@ -1,15 +1,19 @@
|
||||
# $NetBSD: directive-unexport-env.mk,v 1.5 2020/12/06 17:29:27 rillig Exp $
|
||||
# $NetBSD: directive-unexport-env.mk,v 1.6 2020/12/12 18:00:18 rillig Exp $
|
||||
#
|
||||
# Tests for the .unexport-env directive.
|
||||
#
|
||||
# Before 2020-12-13, the directive unexport-env wrongly accepted arguments
|
||||
# and ignored them.
|
||||
#
|
||||
# Before 2020-12-13, misspelled directive names like "unexport-environment"
|
||||
# were not properly detected.
|
||||
|
||||
# TODO: Implementation
|
||||
|
||||
.unexport-en # oops: misspelled
|
||||
.unexport-env # ok
|
||||
.unexport-environment # oops: misspelled
|
||||
.unexport-environment # misspelled
|
||||
|
||||
# As of 2020-12-06, the directive unexport-env is not supposed to accept
|
||||
# arguments, but it does without complaining about them.
|
||||
.MAKEFLAGS: -dv
|
||||
UT_EXPORTED= value
|
||||
UT_UNEXPORTED= value
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: var.c,v 1.722 2020/12/12 00:53:23 rillig Exp $ */
|
||||
/* $NetBSD: var.c,v 1.723 2020/12/12 18:00:18 rillig Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1989, 1990, 1993
|
||||
@ -130,7 +130,7 @@
|
||||
#include "metachar.h"
|
||||
|
||||
/* "@(#)var.c 8.3 (Berkeley) 3/19/94" */
|
||||
MAKE_RCSID("$NetBSD: var.c,v 1.722 2020/12/12 00:53:23 rillig Exp $");
|
||||
MAKE_RCSID("$NetBSD: var.c,v 1.723 2020/12/12 18:00:18 rillig Exp $");
|
||||
|
||||
/* A string that may need to be freed after use. */
|
||||
typedef struct FStr {
|
||||
@ -751,20 +751,30 @@ ClearEnv(void)
|
||||
}
|
||||
|
||||
static void
|
||||
GetVarnamesToUnexport(const char *str,
|
||||
GetVarnamesToUnexport(const char *directive,
|
||||
FStr *out_varnames, UnexportWhat *out_what)
|
||||
{
|
||||
UnexportWhat what;
|
||||
FStr varnames = FSTR_INIT;
|
||||
const char *p = directive;
|
||||
|
||||
str += strlen("unexport");
|
||||
if (strncmp(str, "-env", 4) == 0)
|
||||
p += strlen("unexport");
|
||||
if (strncmp(p, "-env", 4) == 0) {
|
||||
if (ch_isspace(p[4])) {
|
||||
Parse_Error(PARSE_FATAL,
|
||||
"The directive .unexport-env does not take "
|
||||
"arguments");
|
||||
} else if (p[4] != '\0') {
|
||||
Parse_Error(PARSE_FATAL,
|
||||
"Unknown directive \"%s\"", directive);
|
||||
}
|
||||
what = UNEXPORT_ENV;
|
||||
else {
|
||||
cpp_skip_whitespace(&str);
|
||||
what = str[0] != '\0' ? UNEXPORT_NAMED : UNEXPORT_ALL;
|
||||
|
||||
} else {
|
||||
cpp_skip_whitespace(&p);
|
||||
what = p[0] != '\0' ? UNEXPORT_NAMED : UNEXPORT_ALL;
|
||||
if (what == UNEXPORT_NAMED)
|
||||
FStr_Assign(&varnames, str, NULL);
|
||||
FStr_Assign(&varnames, p, NULL);
|
||||
}
|
||||
|
||||
if (what != UNEXPORT_NAMED) {
|
||||
|
Loading…
Reference in New Issue
Block a user