diff options
author | harti <harti@FreeBSD.org> | 2005-05-13 06:31:45 +0000 |
---|---|---|
committer | harti <harti@FreeBSD.org> | 2005-05-13 06:31:45 +0000 |
commit | 591461b255820286bc3bff9255be4670505ef9f6 (patch) | |
tree | 0d921aefa72a95b0e6d2ec580aceb1015b622ec0 /usr.bin/make/job.c | |
parent | f320f90aa13e4dc5d52bb9938d2a0827f115002e (diff) | |
download | FreeBSD-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.
Diffstat (limited to 'usr.bin/make/job.c')
-rw-r--r-- | usr.bin/make/job.c | 18 |
1 files changed, 9 insertions, 9 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; |