1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 18:35:32 +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. * Parse array of "ENV=value" pairs to Properties.
*/ */
private Properties parseEnv(String[] env) { private void parseEnvironment(String[] env) {
Properties envProperties = new Properties(); fEnvironment = null;
if (env != null) {
fEnvironment = new Properties();
for (String envStr : env) { for (String envStr : env) {
// Split "ENV=value" and put in Properties // Split "ENV=value" and put in Properties
int pos = envStr.indexOf('='); int pos = envStr.indexOf('=');
@ -136,9 +138,9 @@ public class CommandLauncher implements ICommandLauncher {
pos = envStr.length(); pos = envStr.length();
String key = envStr.substring(0, pos); String key = envStr.substring(0, pos);
String value = envStr.substring(pos + 1); 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 @Override
public Process execute(IPath commandPath, String[] args, String[] env, IPath workingDirectory, IProgressMonitor monitor) throws CoreException { 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; Boolean isFound = null;
String command = commandPath.toOSString(); String command = commandPath.toOSString();
String envPathValue = (String) getEnvironment().get(PATH_ENV);
try {
fCommandArgs = constructCommandArray(command, args); fCommandArgs = constructCommandArray(command, args);
if (Platform.getOS().equals(Platform.OS_WIN32)) { if (Platform.getOS().equals(Platform.OS_WIN32)) {
// Handle cygwin link // Handle cygwin link
@ -180,9 +183,9 @@ public class CommandLauncher implements ICommandLauncher {
} }
} }
fEnvironment = parseEnv(env);
File dir = workingDirectory != null ? workingDirectory.toFile() : null; File dir = workingDirectory != null ? workingDirectory.toFile() : null;
try {
fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, dir); fProcess = ProcessFactory.getFactory().exec(fCommandArgs, env, dir);
fCommandArgs[0] = command; // to print original command on the console fCommandArgs[0] = command; // to print original command on the console
fErrorMessage = ""; //$NON-NLS-1$ fErrorMessage = ""; //$NON-NLS-1$