1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

bug 364733: Fixed problem with not picking environment correctly

This commit is contained in:
Andrew Gvozdev 2012-03-18 06:17:19 -04:00
parent 4b719a56c7
commit 13ab9fa3c4

View file

@ -127,8 +127,10 @@ public class CommandLauncher implements ICommandLauncher {
/**
* Parse array of "ENV=value" pairs to Properties.
*/
private Properties parseEnv(String[] env) {
Properties envProperties = new Properties();
private void parseEnvironment(String[] env) {
fEnvironment = null;
if (env != null) {
fEnvironment = new Properties();
for (String envStr : env) {
// Split "ENV=value" and put in Properties
int pos = envStr.indexOf('=');
@ -136,9 +138,9 @@ public class CommandLauncher implements ICommandLauncher {
pos = envStr.length();
String key = envStr.substring(0, pos);
String value = envStr.substring(pos + 1);
envProperties.put(key, value);
fEnvironment.put(key, value);
}
}
return envProperties;
}
/**
@ -162,10 +164,11 @@ public class CommandLauncher implements ICommandLauncher {
*/
@Override
public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor) throws CoreException {
parseEnvironment(env);
String envPathValue = (String) getEnvironment().get(PATH_ENV);
Boolean isFound = null;
String command = commandPath.toOSString();
String envPathValue = (String) getEnvironment().get(PATH_ENV);
try {
fCommandArgs = constructCommandArray(command, args);
if (Platform.getOS().equals(Platform.OS_WIN32)) {
// Handle cygwin link
@ -180,9 +183,9 @@ public class CommandLauncher implements ICommandLauncher {
}
}
fEnvironment = parseEnv(env);
File dir = workingDirectory != null ? workingDirectory.toFile() : null;
try {
fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, dir);
fCommandArgs[0] = command; // to print original command on the console
fErrorMessage = ""; //$NON-NLS-1$