[INTERPRETER]

* NEW: Defining the PWD environment variable in a SHELL or EXEC instruction
  changes the working directory of the child process.


git-svn-id: svn://localhost/gambas/trunk@5569 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2013-03-02 22:42:05 +00:00
parent 84f819541a
commit 514b6a95a5

View file

@ -405,6 +405,7 @@ static void run_process(CPROCESS *process, int mode, void *cmd, CARRAY *env)
CARRAY *array;
int i, n;
sigset_t sig, old;
bool pwd;
/* for terminal */
int fd_master = -1;
@ -669,8 +670,7 @@ static void run_process(CPROCESS *process, int mode, void *cmd, CARRAY *env)
}
}
// Return to the parent working directory
FILE_chdir(PROJECT_oldcwd);
pwd = FALSE;
if (env)
{
@ -681,9 +681,15 @@ static void run_process(CPROCESS *process, int mode, void *cmd, CARRAY *env)
str = ((char **)env->data)[i];
if (putenv(str))
ERROR_warning("cannot set environment string: %s", str);
if (strncmp(str, "PWD=", 4) == 0 && chdir(&str[4]) == 0)
pwd = TRUE;
}
}
// Return to the parent working directory if the PWD environment variable has not been set
if (!pwd)
FILE_chdir(PROJECT_oldcwd);
execvp(argv[0], (char **)argv);
//execve(argv[0], (char **)argv, environ);
abort_child(CHILD_CANNOT_EXEC);