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.
This commit is contained in:
Hartmut Brandt 2005-05-13 06:31:45 +00:00
parent 0749600611
commit 5a7a21e591
2 changed files with 9 additions and 10 deletions

View File

@ -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;
} else {
path += 1;
}
if ((newShell.name = strrchr(path, '/')) == NULL) {
newShell.name = path;
} else {
newShell.name += 1;
}
}
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;

View File

@ -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);