Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2015-12-16 08:34:47 +0000
committerAnton Leherbauer2015-12-16 08:34:47 +0000
commitba2226dfc41ddc21743f9570b5d67bd94f072f54 (patch)
tree9b2e40a706447002d1daec61816528ccfcf1a32a /target_explorer/plugins
parent8d2e34a0d12bb5fcf4646b717a46f751307067d4 (diff)
downloadorg.eclipse.tcf-ba2226dfc41ddc21743f9570b5d67bd94f072f54.tar.gz
org.eclipse.tcf-ba2226dfc41ddc21743f9570b5d67bd94f072f54.tar.xz
org.eclipse.tcf-ba2226dfc41ddc21743f9570b5d67bd94f072f54.zip
Target Explorer: Fix handling of exported bash functions in environment
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/utils/Env.java28
1 files changed, 15 insertions, 13 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/utils/Env.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/utils/Env.java
index 9576e6e55..e50280baf 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/utils/Env.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime/src/org/eclipse/tcf/te/runtime/utils/Env.java
@@ -78,8 +78,10 @@ public class Env {
// The full provided variable in form "name=value"
String envpPart = envp[i];
// Split the variable
- String[] parts = envpPart.split("=");//$NON-NLS-1$
- String name = parts[0].trim();
+ int eqIdx = envpPart.indexOf('=');
+ if (eqIdx < 1)
+ continue;
+ String name = envpPart.substring(0, eqIdx);
// Map the variable name to the real environment name (Windows only)
if (Host.isWindowsHost()) {
if (k2n.containsKey(name.toLowerCase())) {
@@ -88,12 +90,12 @@ public class Env {
name = candidate;
}
// Filter out environment variables with bad names
- if ("".equals(name.trim()) || name.contains("=") || name.contains(":")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if ("".equals(name.trim()) || name.contains(":")) { //$NON-NLS-1$ //$NON-NLS-2$
continue;
}
}
// Get the variable value
- String value = parts.length > 1 ? parts[1].trim() : ""; //$NON-NLS-1$
+ String value = envpPart.substring(eqIdx+1);
// Don't overwrite the TERM variable if in terminal mode
if (terminal && "TERM".equals(name)) continue; //$NON-NLS-1$
// If a variable with the name does not exist, just append it
@@ -172,20 +174,22 @@ public class Env {
BufferedReader reader = new BufferedReader(isreader);
try {
String line = reader.readLine();
- String key = null;
- String value = null;
while (line != null) {
+ String key = null;
+ String value = null;
int func = line.indexOf("=()"); //$NON-NLS-1$
if (func > 0) {
key = line.substring(0, func);
// scan until we find the closing '}' with no following chars
value = line.substring(func + 1);
- while (line != null && !line.equals("}")) { //$NON-NLS-1$
+ do {
line = reader.readLine();
- if (line != null) {
- value += line;
- }
- }
+ if (line == null)
+ break;
+ if (line.equals("}")) //$NON-NLS-1$
+ value += ';';
+ value += ' ' + line;
+ } while (!line.equals("}")); //$NON-NLS-1$
line = reader.readLine();
} else {
int separator = line.indexOf('=');
@@ -213,8 +217,6 @@ public class Env {
}
if (key != null) {
cache.put(key, value);
- key = null;
- value = null;
} else {
line = reader.readLine();
}

Back to the top