@@ -55,6 +55,36 @@ RCUTILS_WARN_UNUSED
5555bool
5656rcutils_set_env (const char * env_name , const char * env_value );
5757
58+ /// Set or un-set a process-scoped environment variable while specifying overwrite behavior.
59+ /**
60+ * This function modifies the environment variables for the current process by
61+ * copying given string values into the process' global environment variable
62+ * store.
63+ *
64+ * \par Thread Safety:
65+ * This function is not thread-safe. Take care not to modify the environment variables while
66+ * another thread might be reading or writing environment variables.
67+ *
68+ * \par Platform Consistency:
69+ * The behavior when setting a variable to an empty string (`""`) differs
70+ * between platforms. On Windows, the variable is un-set (as if \p env_value was
71+ * `NULL`), while on other platforms the variable is set to an empty string as
72+ * expected.
73+ *
74+ * \param[in] env_name Name of the environment variable to modify.
75+ * \param[in] env_value Value to set the environment variable to, or `NULL` to
76+ * un-set.
77+ * \param[in] overwrite If true, the environemnt variable value will not be overwritten
78+ * if previously set.
79+ * \return `true` if success, or
80+ * \return `false` if env_name is invalid or NULL, or
81+ * \return `false` on failure.
82+ */
83+ RCUTILS_PUBLIC
84+ RCUTILS_WARN_UNUSED
85+ bool
86+ rcutils_set_env_overwrite (const char * env_name , const char * env_value , bool overwrite );
87+
5888/// Retrieve the value of the given environment variable if it exists, or "".
5989/** The c-string which is returned in the env_value output parameter is only
6090 * valid until the next time this function is called, because it is a direct
0 commit comments