List<String> (@NotNull String browserPathOrName, @Nullable String url, @NotNull List<String> parameters, boolean newWindowIfPossible) { var command = new ArrayList<String>(); var path = NioFiles.toPath(browserPathOrName); if (path == null || !Files.isRegularFile(path)) { if (SystemInfo.isMac) { command.addAll(List.of(ExecUtil.getOpenCommandPath(), "-a", browserPathOrName)); if (newWindowIfPossible) { command.add("-n"); } if (url != null) { command.add(url); } if (!parameters.isEmpty()) { command.add("--args"); command.addAll(parameters); } } else if (SystemInfo.isWindows) { command.addAll(List.of(ExecUtil.getWindowsShellName(), "/c", "start", GeneralCommandLine.inescapableQuote(""), browserPathOrName)); command.addAll(parameters); if (url != null) { command.add(url); } } } if (command.isEmpty()) { command.add(browserPathOrName); command.addAll(parameters); if (url != null) { command.add(url); } } return command; }