act on child_envp instead of global environment variables

This commit is contained in:
slonkazoid 2024-09-08 18:22:06 +03:00
parent f7d611af7b
commit 124b1f1248
No known key found for this signature in database

View File

@ -1,14 +1,17 @@
#define _POSIX_C_SOURCE 200809L
#include <stdlib.h>
#include <glib.h>
#include "sway/commands.h"
extern char **child_envp;
struct cmd_results *cmd_env(int argc, char **argv) {
struct cmd_results *error = NULL;
if ((error = checkarg(argc, "env", EXPECTED_EQUAL_TO, 2))) {
return error;
}
setenv(argv[0], argv[1], 1);
child_envp = g_environ_setenv(child_envp, argv[0], argv[1], 1);
return cmd_results_new(CMD_SUCCESS, NULL);
}