summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharti <harti@FreeBSD.org>2005-05-13 06:31:45 +0000
committerharti <harti@FreeBSD.org>2005-05-13 06:31:45 +0000
commit591461b255820286bc3bff9255be4670505ef9f6 (patch)
tree0d921aefa72a95b0e6d2ec580aceb1015b622ec0
parentf320f90aa13e4dc5d52bb9938d2a0827f115002e (diff)
downloadFreeBSD-src-591461b255820286bc3bff9255be4670505ef9f6.zip
FreeBSD-src-591461b255820286bc3bff9255be4670505ef9f6.tar.gz
Make Shell_Init() static - it's only used here.
Make sure we don't end up with shellPath beeing non-zero, but shellName beeing zero in the error case - back out cleanly from the error. When executing a command for macro assignment in Cmd_Exec() stuff the path of the shell into argv[0], not the name. This makes no difference from the functionality point of view, but allows the regression tests to determine whether make executes the correct shell.
-rw-r--r--usr.bin/make/job.c18
-rw-r--r--usr.bin/make/job.h1
2 files changed, 9 insertions, 10 deletions
diff --git a/usr.bin/make/job.c b/usr.bin/make/job.c
index 523f0b9..34f9f06 100644
--- a/usr.bin/make/job.c
+++ b/usr.bin/make/job.c
@@ -2596,7 +2596,7 @@ JobFreeShell(struct Shell *sh)
}
}
-void
+static void
Shell_Init(void)
{
@@ -3007,28 +3007,28 @@ Job_ParseShell(char *line)
* word and copy it to a new location. In either case, we need
* to record the path the user gave for the shell.
*/
- free(shellPath);
- shellPath = estrdup(path);
+ path = estrdup(path);
if (newShell.name == NULL) {
/* get the base name as the name */
- path = strrchr(path, '/');
- if (path == NULL) {
- path = shellPath;
+ if ((newShell.name = strrchr(path, '/')) == NULL) {
+ newShell.name = path;
} else {
- path += 1;
+ newShell.name += 1;
}
- newShell.name = path;
}
if (!fullSpec) {
if ((sh = JobMatchShell(newShell.name)) == NULL) {
Parse_Error(PARSE_FATAL,
"%s: no matching shell", newShell.name);
+ free(path);
return (FAILURE);
}
} else {
sh = JobCopyShell(&newShell);
}
+ free(shellPath);
+ shellPath = path;
}
/* set the new shell */
@@ -3522,7 +3522,7 @@ Compat_RunCommand(char *cmd, GNode *gn)
* well as -c if it is supposed to exit when it hits an error.
*/
ps.argv = emalloc(4 * sizeof(char *));
- ps.argv[0] = strdup(shellName);
+ ps.argv[0] = strdup(shellPath);
ps.argv[1] = strdup(errCheck ? "-ec" : "-c");
ps.argv[2] = strdup(cmd);
ps.argv[3] = NULL;
diff --git a/usr.bin/make/job.h b/usr.bin/make/job.h
index 0c85c01..e908653 100644
--- a/usr.bin/make/job.h
+++ b/usr.bin/make/job.h
@@ -56,7 +56,6 @@ struct Buffer;
struct GNode;
struct Lst;
-void Shell_Init(void);
void Job_Touch(struct GNode *, Boolean);
Boolean Job_CheckCommands(struct GNode *, void (*abortProc)(const char *, ...));
void Job_CatchChildren(Boolean);
OpenPOWER on IntegriCloud