public final @NotNull Map<String, String> readShellEnv(@Nullable Path file, @Nullable Map<String, String> additionalEnvironment) throws IOException {
      String reader;

      if (SystemInfoRt.isMac) {
        reader = PathManager.findBinFileWithException(MacOS_LOADER_BINARY).toAbsolutePath().toString();
      }
      else {
        reader = SHELL_ENV_COMMAND + "' '" + ENV_ZERO_ARGUMENT;
      }

      // The temporary file is not pre-created, as writing to an already existing file using pipe might not be available
      // if the 'no-clobber' option is set for the shell
      Path envDataFileDir = Files.createTempDirectory("ij-env-tmp-dir");
      Path envDataFile = envDataFileDir.resolve("ij-shell-env-data.tmp");

      StringBuilder readerCmd = new StringBuilder();
      if (file != null) {
        if (!Files.exists(file)) {
          throw new NoSuchFileException(file.toString());
        }
        readerCmd.append(SHELL_SOURCE_COMMAND).append(" \"").append(file).append("\" && ");
      }

      readerCmd.append("'").append(reader).append("' > '").append(envDataFile.toAbsolutePath()).append("'");

      List<String> command = getShellProcessCommand();
      int idx = command.indexOf(SHELL_COMMAND_ARGUMENT);
      if (idx >= 0) {
        // if there is already a command append command to the end
        command.set(idx + 1, command.get(idx + 1) + ';' + readerCmd);
      }
      else {
        command.add(SHELL_COMMAND_ARGUMENT);
        command.add(readerCmd.toString());
      }

      LOG.info("loading shell env: " + String.join(" ", command));
      try {
        return runProcessAndReadOutputAndEnvs(command, null, additionalEnvironment, envDataFile).getValue();
      }
      finally {
        deleteTempFile(envDataFile);
        deleteTempFile(envDataFileDir);
      }
    }
public final @NotNull Map<String, String> readShellEnv(@Nullable Path file, @Nullable Map<String, String> additionalEnvironment)