diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-06-05 23:42:03 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-06-08 18:39:16 +0200 |
commit | 4686d184967c0c747777c8edcc6b00dc023b8aa9 (patch) | |
tree | b3775d06e14450117c4c17b85e87fa635a02c689 /src/main.c | |
parent | 9618aadc5e31c688247f57ac55fe4e97a440f5c3 (diff) | |
download | sciteco-4686d184967c0c747777c8edcc6b00dc023b8aa9.tar.gz |
Windows: normalize $COMSPEC
* Environment variables are case insensitive on Windows
while SciTECO variables are case sensitive.
We must therefore make sure that we first unset any $COMSPEC or $ComSpec
from the environment before resetting it, thereby fixing its case.
* Fixes command execution via <EC> on systems where the variable
was not called $ComSpec.
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -245,7 +245,16 @@ teco_initialize_environment(const gchar *program) g_free(abs_path); #ifdef G_OS_WIN32 - g_setenv("ComSpec", "cmd.exe", FALSE); + /* + * NOTE: Environment variables are case-insensitive on Windows + * and there may be either a $COMSPEC or $ComSpec variable. + * By unsetting and resetting $COMSPEC, we make sure that + * it exists with defined case in the environment and therefore + * as a Q-Register. + */ + g_autofree gchar *comspec = g_strdup(g_getenv("COMSPEC") ? : "cmd.exe"); + g_unsetenv("COMSPEC"); + g_setenv("COMSPEC", comspec, TRUE); #elif defined(G_OS_UNIX) g_setenv("SHELL", "/bin/sh", FALSE); #endif |