Skip to content

Commit

Permalink
fix: Terminal ESP-IDF Path conflict issues (#979)
Browse files Browse the repository at this point in the history
* fix: ESP-IDF Terminal: Conflict path issues

* fix: adding arguments to avoid shell profiles

---------

Co-authored-by: Denys Almazov <[email protected]>
  • Loading branch information
kolipakakondal and sigmaaa authored Sep 23, 2024
1 parent 8c45066 commit 97db593
Showing 1 changed file with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,16 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
.getString(IPreferenceKeys.PREF_LOCAL_TERMINAL_DEFAULT_SHELL_UNIX_ARGS);
}

// Avoding profiles to isolate PATH enviroment
arguments = ""; //$NON-NLS-1$
if (image.contains("bash")) { //$NON-NLS-1$
arguments = "--noprofile --norc"; //$NON-NLS-1$
} else if (image.contains("zsh")) { //$NON-NLS-1$
arguments = "--no-rcs --no-globalrcs"; //$NON-NLS-1$
} else if (image.contains("powershell")) { //$NON-NLS-1$
arguments = "-NoProfile"; //$NON-NLS-1$
}

// Determine if a PTY will be used
boolean isUsingPTY = (properties.get(ITerminalsConnectorConstants.PROP_PROCESS_OBJ) == null
&& PTY.isSupported(PTY.Mode.TERMINAL))
Expand Down Expand Up @@ -375,14 +385,14 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
//Set CDT build environment variables
Map<String, String> envMap = new IDFEnvironmentVariables().getSystemEnvMap();
Set<String> keySet = envMap.keySet();

for (String envKey : keySet) {
String envValue = envMap.get(envKey);
if (envKey.equals("PATH")) //$NON-NLS-1$
{
String idfExtraPaths = IDFUtil.getIDFExtraPaths();
if(!StringUtil.isEmpty(idfExtraPaths))
{
envValue = envValue + ":" + idfExtraPaths; //$NON-NLS-1$
if (!StringUtil.isEmpty(idfExtraPaths)) {
envValue = idfExtraPaths + ":" + envValue; //$NON-NLS-1$
}
}
envpList.add(envKey + "=" + envValue); //$NON-NLS-1$
Expand All @@ -394,11 +404,10 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
Assert.isTrue(image != null || process != null);

String terminalWrkDir = getWorkingDir();
if (StringUtil.isEmpty(terminalWrkDir))
{
if (StringUtil.isEmpty(terminalWrkDir)) {
terminalWrkDir = workingDir;
}

// Construct the terminal settings store
ISettingsStore store = new SettingsStore();

Expand All @@ -420,7 +429,6 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
processSettings
.setMergeWithNativeEnvironment(value instanceof Boolean ? ((Boolean) value).booleanValue() : false);
}

// And save the settings to the store
processSettings.save(store);

Expand All @@ -435,7 +443,7 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties

return connector;
}

protected String getWorkingDir() {
Bundle bundle = Platform.getBundle("org.eclipse.core.resources"); //$NON-NLS-1$
if (bundle != null && bundle.getState() != Bundle.UNINSTALLED && bundle.getState() != Bundle.STOPPING) {
Expand Down

0 comments on commit 97db593

Please sign in to comment.