GeneralCommandLine (DataContext dataContext) { if (StringUtil.isEmpty(getWorkingDirectory())) { setWorkingDirectory("$ProjectFileDir$"); } GeneralCommandLine commandLine = Registry.is("use.tty.for.external.tools", false) ? new PtyCommandLine().withConsoleMode(true) : new GeneralCommandLine(); try { String exePath = MacroManager.getInstance().expandMacrosInString(getProgram(), true, dataContext); exePath = MacroManager.getInstance().expandMacrosInString(exePath, false, dataContext); if (exePath == null) return null; WSLDistribution wsl = WslPath.getDistributionByWindowsUncPath(exePath); MacroPathConverter pathConverter = null; if (wsl != null) { pathConverter = new WslMacroPathConverter(wsl); dataContext = SimpleDataContext.getSimpleContext(MacroManager.PATH_CONVERTER_KEY, pathConverter, dataContext); } String paramString = MacroManager.getInstance().expandMacrosInString(getParameters(), true, dataContext); String workingDir = MacroManager.getInstance().expandMacrosInString(getWorkingDirectory(), true, dataContext); commandLine.getParametersList().addParametersString( MacroManager.getInstance().expandMacrosInString(paramString, false, dataContext)); final String workDirExpanded = MacroManager.getInstance().expandMacrosInString(workingDir, false, dataContext); if (!StringUtil.isEmpty(workDirExpanded)) { commandLine.setWorkDirectory(workDirExpanded); } File exeFile = new File(exePath); if (exeFile.isDirectory() && exeFile.getName().endsWith(".app")) { commandLine.setExePath("open"); commandLine.getParametersList().prependAll("-a", exePath); } else if (wsl != null) { try { commandLine = createWslCommandLine(CommonDataKeys.PROJECT.getData(dataContext), wsl, commandLine, workDirExpanded, pathConverter.convertPath(exePath)); } catch (ExecutionException e) { LOG.error("Failed to create wsl command line", e); } } else { commandLine.setExePath(exePath); } } catch (Macro.ExecutionCancelledException ignored) { return null; } return ToolsCustomizer.customizeCommandLine(commandLine, dataContext); }