1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 336013: [launch] Environment variables that contain a space are not properly set at launch time

This commit is contained in:
Marc Khouzam 2011-02-02 02:14:28 +00:00
parent 54ef22fda2
commit 9c4c909ba9

View file

@ -32,14 +32,17 @@ public class MIGDBSetEnv extends MIGDBSet
} }
public MIGDBSetEnv(ICommandControlDMContext dmc, String name, String value) { public MIGDBSetEnv(ICommandControlDMContext dmc, String name, String value) {
// We need to avoid putting "" around the variable. // MICommand wraps a parameter with double quotes if it contains a space. If the
// -gdb-set env "MYVAR=MY VAR" // value of the environment variable has a space, and we bundle the var name, the
// will not set MYVAR to MY VAR, but instead will create an empty variable with name "MYVAR=MY VAR" // '=' and the value as a single parameter, then we'll end up with something like
// This is because "" are automatically inserted if there is a space in the parameter. //
// What we really want to send is: // -gdb-set env "MYVAR=MY VAR"
// -gdb-set env MYVAR=MY VAR //
// To achieve that, we split the value into separate parameters // which defines an environment variable named "MYVAR=MY VAR", with an empty
super(dmc, null); // string for a value. To avoid this, we send each element as a separate parameter
//
// -gdb-set env MYVAR = MY VAR
super(dmc, null);
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {
setParameters(new String[] { "env", name }); //$NON-NLS-1$ setParameters(new String[] { "env", name }); //$NON-NLS-1$