Joćo Assirati contributed a 'less horrible, less leaky' putenv function in src/support/putenv.C. It's currently used only by src/lyxsocket.C.
We also have putEnv in src/support/filetools.C. It has the same signature as Joćo's function but uses either ::setenv or ::putenv internally with a preference for ::setenv if it exists. The use of ::putenv is 'more leaky' than Joćo's function. I'd like to merge Joćo's function into the putEnv in src/support/filetools.C, getting rid of src/support/putenv.C in the process. Whilst we're at it, it seems sensible to also move these four functions into their own env_var.[Ch] file. They're nothing at all to do with filetools. Lars, are you happy with such a change? Angus /// \returns the contents of the environment variable \c name. std::string const getEnv(std::string const & name); /** Return the contents of the environment variable \c name, * split into elements using the OS-dependent separator token. * Each element is then passed through os::internal_path to * guarantee that it is in the form of a unix-style path. * If the environment variable is not set, then returns an empty vector. */ std::vector<std::string> const getEnvPath(std::string const & name); /** Set the contents of the environment variable \c name to \c value. * \returns true if the variable was set successfully. */ bool setEnv(std::string const & name, std::string const & value); /** Set the contents of the environment variable \c name * using the paths stored in the \c env vector. * Each element is passed through os::external_path(). * Multiple elements are concatenated into a single string using * os::path_separator(). */ void setEnvPath(std::string const & name, std::vector<std::string> const & env); /** Prepend a list of paths to that returned by the environment variable. * Identical paths occurring later in the list are removed. * @param name the name of the environment variable. * @prefix the list of paths in OS-native syntax. * Eg "/foo/bar:/usr/bin:/usr/local/bin" on *nix, * "C:\foo\bar;C:\windows" on Windows. */ void prependEnvPath(std::string const & name, std::string const & prefix);