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,13 +32,16 @@ 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
// value of the environment variable has a space, and we bundle the var name, the
// '=' and the value as a single parameter, then we'll end up with something like
//
// -gdb-set env "MYVAR=MY VAR" // -gdb-set env "MYVAR=MY VAR"
// will not set MYVAR to MY VAR, but instead will create an empty variable with name "MYVAR=MY VAR" //
// This is because "" are automatically inserted if there is a space in the parameter. // which defines an environment variable named "MYVAR=MY VAR", with an empty
// What we really want to send is: // string for a value. To avoid this, we send each element as a separate parameter
// -gdb-set env MYVAR=MY VAR //
// To achieve that, we split the value into separate parameters // -gdb-set env MYVAR = MY VAR
super(dmc, null); super(dmc, null);
if (value == null || value.length() == 0) { if (value == null || value.length() == 0) {