aboutsummaryrefslogtreecommitdiff
path: root/terminal.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-01-09 15:50:47 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-01-11 15:37:17 +0000
commit9da7152f834384a354710fcc8f99a6f83e5dfc12 (patch)
treed5dffcbe9133d87a034bf32d09b3ef25f4ddc610 /terminal.c
parentconfig: fix cloning of env_vars tllist (diff)
slave: don't skip setting environment variables when using a custom environment
When launching footclient with -E,--client-environment the environment variables that should be set by foot, wasn't. Those variables are: * TERM * COLORTERM * PWD * SHELL and all variables defined by the user in the [environment] section in foot.ini. In the same way, we did not *unset* TERM_PROGRAM and TERM_PROGRAM_VERSION. This patch fixes it by "cloning" the custom environment, making it mutable, and then adding/removing the variables above from it. Instead of calling setenv()/unsetenv() directly, we add the wrapper functions add_to_env() and del_from_env(). When *not* using a custom environment, they simply call setenv()/unsetenv(). When we *are* using a custom environment, add_to_env() first loops all existing variables, looking for a match. If a match is found, it's updated with the new value. If it's not found, a new entry is added. del_from_env() loops all entries, and removes it when a match is found. If no match is found, nothing is done. The mutable environment is allocated on the heap, but never free:d. We don't need to free it, since it's only allocated after forking, in the child process. Closes #1568
Diffstat (limited to 'terminal.c')
-rw-r--r--terminal.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/terminal.c b/terminal.c
index efbbded1..5332ada0 100644
--- a/terminal.c
+++ b/terminal.c
@@ -1061,7 +1061,7 @@ static void fdm_client_terminated(
struct terminal *
term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
struct wayland *wayl, const char *foot_exe, const char *cwd,
- const char *token, int argc, char *const *argv, char *const *envp,
+ const char *token, int argc, char *const *argv, const char *const *envp,
void (*shutdown_cb)(void *data, int exit_code), void *shutdown_data)
{
int ptmx = -1;