From 09fec961f4371aa0c35c2e0ddc901e1901efc0e1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 14:23:16 +0000 Subject: [PATCH 1/3] Initial plan From d08314f96735a4b3141f65081b134f9c1983da2b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:57:34 +0000 Subject: [PATCH 2/3] Update Dmod_SetEnv to match new DMOD API signature Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com> --- src/dmenv.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/dmenv.c b/src/dmenv.c index 5ba4c58..94b39d6 100644 --- a/src/dmenv.c +++ b/src/dmenv.c @@ -467,17 +467,32 @@ DMOD_INPUT_API_DECLARATION(dmenv, 1.0, size_t, _count, (dmenv_ctx_t ctx)) * * @param Name Name of the environment variable * @param Value Value to set - * @return bool true if successful, false otherwise + * @param Overwrite If non-zero, overwrite existing variable; if zero, keep existing value + * @return int 0 if successful, non-zero otherwise */ -DMOD_INPUT_API_DECLARATION(Dmod, 1.0, bool, _SetEnv, (const char *Name, const char *Value)) +DMOD_INPUT_API_DECLARATION(Dmod, 1.0, int, _SetEnv, (const char *Name, const char *Value, int Overwrite)) { dmenv_ctx_t ctx = dmenv_get_default(); if (ctx == NULL) { DMOD_LOG_ERROR("No default context set for Dmod_SetEnv\n"); - return false; + return -1; + } + + // If Overwrite is 0 and variable already exists, return success without updating + if (Overwrite == 0) + { + const char *existing = dmenv_get(ctx, Name); + if (existing != NULL) + { + DMOD_LOG_VERBOSE("Variable %s already exists, not overwriting\n", Name); + return 0; + } } - return dmenv_set(ctx, Name, Value); + + // Set or update the variable + bool result = dmenv_set(ctx, Name, Value); + return result ? 0 : -1; } /** From 242d429d116ae401586e4e9c0b48bccb533fd48e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 7 Nov 2025 18:59:15 +0000 Subject: [PATCH 3/3] Improve documentation clarity for Dmod_SetEnv return value Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com> --- src/dmenv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dmenv.c b/src/dmenv.c index 94b39d6..b86698f 100644 --- a/src/dmenv.c +++ b/src/dmenv.c @@ -468,7 +468,7 @@ DMOD_INPUT_API_DECLARATION(dmenv, 1.0, size_t, _count, (dmenv_ctx_t ctx)) * @param Name Name of the environment variable * @param Value Value to set * @param Overwrite If non-zero, overwrite existing variable; if zero, keep existing value - * @return int 0 if successful, non-zero otherwise + * @return int 0 if successful, -1 otherwise */ DMOD_INPUT_API_DECLARATION(Dmod, 1.0, int, _SetEnv, (const char *Name, const char *Value, int Overwrite)) {