From b5d463fd80a8aef66813a6ca9647510029f66060 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Fri, 12 Feb 2010 15:57:40 +0000 Subject: [PATCH] [302724] problems with environment variable substitution --- .../miners/command/CommandMinerThread.java | 14 +++++++++++--- .../shells/core/subsystems/RemoteCmdSubSystem.java | 7 ++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java index d2949b3e527..66af3540024 100644 --- a/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java +++ b/rse/plugins/org.eclipse.rse.services.dstore/miners/org/eclipse/rse/internal/dstore/universal/miners/command/CommandMinerThread.java @@ -26,6 +26,7 @@ * David McKnight (IBM) [287305] [dstore] Need to set proper uid for commands when using SecuredThread and single server for multiple clients[ * Peter Wang (IBM) [299422] [dstore] OutputHandler.readLines() not compatible with servers that return max 1024bytes available to be read * David McKnight (IBM) [302174] [dstore] shell init command can potentially get called too late + * David McKnight (IBM) [302724] problems with environment variable substitution *******************************************************************************/ package org.eclipse.rse.internal.dstore.universal.miners.command; @@ -753,9 +754,9 @@ public class CommandMinerThread extends MinerThread DataElement projectEnv = null; if (projectEnvReference != null && (projectEnvReference.size() > 0)) projectEnv = (DataElement) projectEnvReference.get(0); - String[] theEnv = mergeEnvironments(systemEnv, projectEnv); + return theEnv; } @@ -791,6 +792,7 @@ public class CommandMinerThread extends MinerThread String theKey = getKey(theVariable); String theValue = getValue(theVariable); theValue = calculateValue(theValue, varTable); + varTable.put(theKey, theValue); } @@ -872,12 +874,17 @@ public class CommandMinerThread extends MinerThread { if (Character.isJavaIdentifierStart(c)) { + while (nextIndex + 1 < theValue.length() && (Character.isJavaIdentifierPart(c))) { nextIndex++; - c = theValue.charAt(nextIndex); + c = theValue.charAt(nextIndex); + + if (nextIndex + 1 == theValue.length()){ + nextIndex++; + } } - + String v = theValue.substring(index + 1, nextIndex); String replacementValue = findValue(v, theTable, true); theValue.replace(index, nextIndex, replacementValue); @@ -885,6 +892,7 @@ public class CommandMinerThread extends MinerThread } } } + } //If the current char is a %, then simply look for a matching % else if (c == '%' && _isWindows) { diff --git a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java index cb3d1c6a551..7671bb35ec4 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java +++ b/rse/plugins/org.eclipse.rse.subsystems.shells.core/src/org/eclipse/rse/subsystems/shells/core/subsystems/RemoteCmdSubSystem.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2002, 2009 IBM Corporation and others. + * Copyright (c) 2002, 2010 IBM Corporation 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 @@ -22,6 +22,7 @@ * David McKnight (IBM) - [230285] [shells] Remote shells should be restored on quit and re-start of RSE * David McKnight (IBM) - [252708] Saving Profile Job happens when not changing Property Values on Connections * David McKnight (IBM) - [272882] [api] Handle exceptions in IService.initService() + * David McKnight (IBM) [302724] problems with environment variable substitution *******************************************************************************/ package org.eclipse.rse.subsystems.shells.core.subsystems; @@ -302,7 +303,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd { for (int i = userVars.length - 1; i >= 0; i--) { - String userVar = userVars[i]; + String userVar = userVars[i]; String varName = null; int assignIndex = userVar.indexOf('='); if (assignIndex > 0) @@ -310,7 +311,7 @@ public abstract class RemoteCmdSubSystem extends SubSystem implements IRemoteCmd varName = userVar.substring(0, assignIndex + 1); if (isUniqueVariable(combinedVars, varName)) { - combinedVars.add(userVar); + combinedVars.add(0,userVar); } } }