summaryrefslogtreecommitdiff
path: root/usr.bin/make
diff options
context:
space:
mode:
authorHartmut Brandt <harti@FreeBSD.org>2005-05-24 13:14:24 +0000
committerHartmut Brandt <harti@FreeBSD.org>2005-05-24 13:14:24 +0000
commit51fb4c0273c5ab3b77604d2e0be6de76b735886f (patch)
tree04805199734910b1269c0492d0bf6dc09abc8b9b /usr.bin/make
parent8fe799834217e5d3131f05e0eb56e4fec441c07b (diff)
Notes
Diffstat (limited to 'usr.bin/make')
-rw-r--r--usr.bin/make/job.c21
-rw-r--r--usr.bin/make/make.15
2 files changed, 18 insertions, 8 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 49497b3b4e68..c2df52b6385a 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -316,6 +316,8 @@ struct Shell {
ArgArray builtins;
char *meta;
+
+ Boolean unsetenv; /* unsetenv("ENV") before exec */
};
TAILQ_HEAD(Shells, Shell);
@@ -409,7 +411,7 @@ static const char *const shells_init[] = {
"quiet='set -' echo='set -v' filter='set -' "
"hasErrCtl=Y check='set -e' ignore='set +e' "
"echoFlag=v errFlag=e "
- "meta='" SH_META "' builtins='" SH_BUILTINS "'",
+ "meta='" SH_META "' builtins='" SH_BUILTINS "' unsetenv=T",
NULL
};
@@ -646,13 +648,6 @@ Proc_Init()
sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
sa.sa_handler = catch_child;
sigaction(SIGCHLD, &sa, NULL);
-
-#if DEFSHELL == 2
- /*
- * Turn off ENV to make ksh happier.
- */
- unsetenv("ENV");
-#endif
}
/**
@@ -698,6 +693,11 @@ ProcExec(const ProcStuff *ps)
Punt("Cannot dup2: %s", strerror(errno));
}
+ if (commandShell->unsetenv) {
+ /* for the benfit of ksh */
+ unsetenv("ENV");
+ }
+
/*
* The file descriptors for stdin, stdout, or stderr might
* have been marked close-on-exec. Clear the flag on all
@@ -2582,6 +2582,7 @@ JobShellDump(const struct Shell *sh)
for (i = 1; i < sh->builtins.argc; i++)
fprintf(stderr, " '%s'", sh->builtins.argv[i]);
fprintf(stderr, "\n meta='%s'\n", sh->meta);
+ fprintf(stderr, " unsetenv=%d\n", sh->unsetenv);
}
/**
@@ -2670,6 +2671,10 @@ JobParseShellSpec(const char *spec, Boolean *fullSpec)
free(sh->meta);
sh->meta = estrdup(eq);
*fullSpec = TRUE;
+ } else if (strcmp(keyw, "unsetenv") == 0) {
+ sh->unsetenv = (*eq == 'Y' || *eq == 'y' ||
+ *eq == 'T' || *eq == 't');
+ *fullSpec = TRUE;
} else {
Parse_Error(PARSE_FATAL, "unknown keyword in shell "
"specification '%s'", keyw);
diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1
index 2afbe2e29582..a9e6e1ef9412 100644
--- a/usr.bin/make/make.1
+++ b/usr.bin/make/make.1
@@ -1325,6 +1325,11 @@ character not starts with a shell builtin it is executed directly without
invoking a shell.
When one of these strings (or both) is empty all commands are executed
through a shell.
+.It Va unsetenv
+If true remove the
+.Ev ENV
+environment variable before executing any command.
+This is useful for the Korn-shell ksh.
.El
.Pp
Values that are strings must be surrounded by double quotes.