summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-05-24 13:14:24 +0000
committerharti <harti@FreeBSD.org>2005-05-24 13:14:24 +0000
commit6c1f15aa0b3b5827f9587dedd80316843096497c (patch)
tree04805199734910b1269c0492d0bf6dc09abc8b9b
parent103db97f6ecd2a1106c2a14f796c724c6372634c (diff)
downloadFreeBSD-src-6c1f15aa0b3b5827f9587dedd80316843096497c.zip
FreeBSD-src-6c1f15aa0b3b5827f9587dedd80316843096497c.tar.gz
Another shell attribute 'unsetenv' that will cause to unsetenv("ENV")
before executing the shell. Until now this was done when the default shell was the ksh. This failed if the default shell was sh or csh and the user switched to ksh.
-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 49497b3..c2df52b 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 2afbe2e..a9e6e1e 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.
OpenPOWER on IntegriCloud