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-01 20:30:32 +00:00
parent 71ac61e6e2
commit 54ef22fda2

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010 Ericsson and others.
* Copyright (c) 2010, 2011 Ericsson and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -32,6 +32,28 @@ public class MIGDBSetEnv extends MIGDBSet
}
public MIGDBSetEnv(ICommandControlDMContext dmc, String name, String value) {
super(dmc, new String[] { "env", name + (value != null && value.length() > 0 ? "=" + value : "")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
// We need to avoid putting "" around the variable.
// -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.
// What we really want to send is:
// -gdb-set env MYVAR=MY VAR
// To achieve that, we split the value into separate parameters
super(dmc, null);
if (value == null || value.length() == 0) {
setParameters(new String[] { "env", name }); //$NON-NLS-1$
} else {
String[] splitValue = value.split(" "); //$NON-NLS-1$
String[] params = new String[splitValue.length+3];
params[0] = "env"; //$NON-NLS-1$
params[1] = name;
params[2] = "="; //$NON-NLS-1$
for (int i=3; i<params.length; i++) {
params[i] = splitValue[i-3];
}
setParameters(params);
}
}
}