Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Khouzam2011-02-01 16:00:20 -0500
committerMarc Khouzam2011-02-01 16:00:20 -0500
commit546fa4a7d0e1600b45495e079ea11584debdc404 (patch)
tree6d8320a3ae137e377019f8036809adfbb883ec62
parentf928a490dafb409a5329d3bd979a7011c1a6aae2 (diff)
downloadorg.eclipse.cdt-546fa4a7d0e1600b45495e079ea11584debdc404.tar.gz
org.eclipse.cdt-546fa4a7d0e1600b45495e079ea11584debdc404.tar.xz
org.eclipse.cdt-546fa4a7d0e1600b45495e079ea11584debdc404.zip
Bug 336013: [launch] Environment variables that contain a space are not properly set at launch time
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetEnv.java30
1 files changed, 26 insertions, 4 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetEnv.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetEnv.java
index 5b5254777b..1c0838b9d5 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetEnv.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIGDBSetEnv.java
@@ -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$
- }
-} \ No newline at end of file
+ // 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);
+ }
+ }
+}

Back to the top