aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--doc/sciteco.1.in10
-rw-r--r--src/interface-curses/interface.c5
-rw-r--r--src/main.c11
-rw-r--r--src/spawn.c6
4 files changed, 25 insertions, 7 deletions
diff --git a/doc/sciteco.1.in b/doc/sciteco.1.in
index 5441621..6747c5e 100644
--- a/doc/sciteco.1.in
+++ b/doc/sciteco.1.in
@@ -242,15 +242,19 @@ Initialization of this variable ensures that the
\(lq$HOME\(rq Q-Register is available even on Windows
and the home directory can always be re-configured.
.TP
-.SCITECO_TOPIC "$SHELL" "SHELL" "$ComSpec" "ComSpec"
-.BR SHELL " or " ComSpec
+.SCITECO_TOPIC "$SHELL" "SHELL" "$COMSPEC" "COMSPEC"
+.BR SHELL " or " COMSPEC
Path of the command interpreter used by \fBEG\fP and \fBEC\fP
commands if UNIX98 shell emulation is \fIdisabled\fP.
-\fBSHELL\fP is used on UNIX-like systems, while \fBComSpec\fP
+\fBSHELL\fP is used on UNIX-like systems, while \fBCOMSPEC\fP
is used on DOS-like systems (like Windows).
Both variables are usually already set in the process environment
but are initialized to \(lq/bin/sh\(rq or \(lqcmd.exe\(rq
should they nevertheless be unset.
+Since environment variables are case-insensitive on
+DOS-like systems and different spellings exist for \fBCOMSPEC\fP,
+the name of the variable is always normalized to all-upper-case
+by \*(ST.
.TP
.SCITECO_TOPIC "$SCITECOCONFIG" "SCITECOCONFIG"
.B SCITECOCONFIG
diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c
index 821581b..0c059ba 100644
--- a/src/interface-curses/interface.c
+++ b/src/interface-curses/interface.c
@@ -30,6 +30,11 @@
#ifdef HAVE_WINDOWS_H
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+
+/*
+ * Some macros in wincon.h interfere with our code.
+ */
+#undef MOUSE_MOVED
#endif
#ifdef EMSCRIPTEN
diff --git a/src/main.c b/src/main.c
index 3d149d4..38b1197 100644
--- a/src/main.c
+++ b/src/main.c
@@ -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
diff --git a/src/spawn.c b/src/spawn.c
index 00ff3ad..be2489b 100644
--- a/src/spawn.c
+++ b/src/spawn.c
@@ -83,7 +83,7 @@ teco_parse_shell_command_line(const gchar *cmdline, GError **error)
#ifdef G_OS_WIN32
if (!(teco_ed & TECO_ED_SHELLEMU)) {
- teco_qreg_t *reg = teco_qreg_table_find(&teco_qreg_table_globals, "$ComSpec", 8);
+ teco_qreg_t *reg = teco_qreg_table_find(&teco_qreg_table_globals, "$COMSPEC", 8);
g_assert(reg != NULL);
teco_string_t comspec;
if (!reg->vtable->get_string(reg, &comspec.data, &comspec.len, error))
@@ -91,7 +91,7 @@ teco_parse_shell_command_line(const gchar *cmdline, GError **error)
argv = g_new(gchar *, 5);
/*
- * FIXME: What if $ComSpec contains null-bytes?
+ * FIXME: What if $COMSPEC contains null-bytes?
*/
argv[0] = comspec.data;
argv[1] = g_strdup("/q");
@@ -414,7 +414,7 @@ gboolean teco_state_execute_process_edit_cmd(teco_machine_main_t *ctx, teco_mach
*
* <command> execution is by default platform-dependent.
* On DOS-like systems like Windows, <command> is passed to
- * the command interpreter specified in the \fB$ComSpec\fP
+ * the command interpreter specified in the \fB$COMSPEC\fP
* environment variable with the \(lq/q\(rq and \(lq/c\(rq
* command-line arguments.
* On UNIX-like systems, <command> is passed to the interpreter