private Map<String, String> getMacroMap() {
    if (myMacroMap == null) {
      // the insertion order is important for later iterations, so LinkedHashMap is used
      myMacroMap = new LinkedHashMap<String, String>();

      // ApplicationManager.getApplication() will return null if executed in ParameterListTest
      final Application application = ApplicationManager.getApplication();
      if (application != null) {
        final PathMacros pathMacros = PathMacros.getInstance();
        for (String name : pathMacros.getUserMacroNames()) {
          final String value = pathMacros.getValue(name);
          if (value != null) {
            myMacroMap.put("${" + name + "}", value);
          }
        }
        final Map<String, String> env = EnvironmentUtil.getEnvironmentProperties();
        for (String name : env.keySet()) {
          final String key = "${" + name + "}";
          if (!myMacroMap.containsKey(key)) {
            myMacroMap.put(key, env.get(name));
          }
        }
      }
    }
    return myMacroMap;
  }
  protected synchronized void execute(GeneralCommandLine commandLine)
      throws AuthenticationException {
    try {
      commandLine.getEnvironment().clear();
      commandLine.getEnvironment().putAll(EnvironmentUtil.getEnvironmentProperties());
      myProcess = commandLine.createProcess();

      myErrThread =
          new ReadProcessThread(
              new BufferedReader(
                  new InputStreamReader(
                      myProcess.getErrorStream(),
                      EncodingManager.getInstance().getDefaultCharset()))) {
            protected void textAvailable(String s) {
              myErrorText.append(s);
              myErrorRegistry.registerError(s);
              myContainsError = true;
            }
          };
      final Application application = ApplicationManager.getApplication();
      myStdErrFuture = application.executeOnPooledThread(myErrThread);

      myInputStream = myProcess.getInputStream();
      myOutputStream = myProcess.getOutputStream();

      waitForProcess(application);
    } catch (Exception e) {
      closeInternal();
      throw new AuthenticationException(e.getLocalizedMessage(), e);
    }
  }
  private void setupEnvironment(final Map<String, String> environment) {
    environment.clear();

    if (myPassParentEnvironment) {
      environment.putAll(EnvironmentUtil.getEnvironmentMap());
    }

    if (!myEnvParams.isEmpty()) {
      if (SystemInfo.isWindows) {
        THashMap<String, String> envVars =
            new THashMap<String, String>(CaseInsensitiveStringHashingStrategy.INSTANCE);
        envVars.putAll(environment);
        envVars.putAll(myEnvParams);
        environment.clear();
        environment.putAll(envVars);
      } else {
        environment.putAll(myEnvParams);
      }
    }
  }
  protected void setupEnvironment(@NotNull Map<String, String> environment) {
    environment.clear();

    if (myPassParentEnvironment) {
      environment.putAll(
          PlatformUtils.isAppCode()
              ? System.getenv() // Temporarily fix for OC-8606
              : EnvironmentUtil.getEnvironmentMap());
    }

    if (!myEnvParams.isEmpty()) {
      if (SystemInfo.isWindows) {
        THashMap<String, String> envVars =
            new THashMap<String, String>(CaseInsensitiveStringHashingStrategy.INSTANCE);
        envVars.putAll(environment);
        envVars.putAll(myEnvParams);
        environment.clear();
        environment.putAll(envVars);
      } else {
        environment.putAll(myEnvParams);
      }
    }
  }