diff options
-rw-r--r-- | doc/sciteco.1.in | 9 | ||||
-rw-r--r-- | src/main.cpp | 6 | ||||
-rw-r--r-- | src/spawn.cpp | 45 |
3 files changed, 43 insertions, 17 deletions
diff --git a/doc/sciteco.1.in b/doc/sciteco.1.in index 468c060..bb7d29b 100644 --- a/doc/sciteco.1.in +++ b/doc/sciteco.1.in @@ -208,6 +208,15 @@ 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 +.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 +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. +.TP .B SCITECOCONFIG Path where \*(ST looks for configuration files. For instance, this is the path of the default profile. diff --git a/src/main.cpp b/src/main.cpp index bf25c73..d14e2e5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -247,6 +247,12 @@ initialize_environment(const gchar *program) g_setenv("HOME", abs_path, TRUE); g_free(abs_path); +#ifdef G_OS_WIN32 + g_setenv("COMSPEC", "cmd.exe", FALSE); +#elif defined(G_OS_UNIX) || defined(G_OS_HAIKU) + g_setenv("SHELL", "/bin/sh", FALSE); +#endif + /* * Initialize $SCITECOCONFIG and $SCITECOPATH */ diff --git a/src/spawn.cpp b/src/spawn.cpp index fce7209..9ea3919 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -97,17 +97,24 @@ parse_shell_command_line(const gchar *cmdline, GError **error) #ifdef G_OS_WIN32 if (!(Flags::ed & Flags::ED_SHELLEMU)) { - const gchar *argv_win32[] = { - "cmd.exe", "/q", "/c", cmdline, NULL - }; - return g_strdupv((gchar **)argv_win32); + QRegister *reg = QRegisters::globals["$COMSPEC"]; + argv = (gchar **)g_malloc(5*sizeof(gchar *)); + argv[0] = reg->get_string(); + argv[1] = g_strdup("/q"); + argv[2] = g_strdup("/c"); + argv[3] = g_strdup(cmdline); + argv[4] = NULL; + return argv; } #elif defined(G_OS_UNIX) || defined(G_OS_HAIKU) if (!(Flags::ed & Flags::ED_SHELLEMU)) { - const gchar *argv_unix[] = { - "/bin/sh", "-c", cmdline, NULL - }; - return g_strdupv((gchar **)argv_unix); + QRegister *reg = QRegisters::globals["$SHELL"]; + argv = (gchar **)g_malloc(4*sizeof(gchar *)); + argv[0] = reg->get_string(); + argv[1] = g_strdup("-c"); + argv[2] = g_strdup(cmdline); + argv[3] = NULL; + return argv; } #endif @@ -178,12 +185,16 @@ parse_shell_command_line(const gchar *cmdline, GError **error) * specific process exit code. * * <command> execution is by default platform-dependent. - * On Windows, <command> is passed to the default command - * interpreter \(lqcmd.exe\(rq with the \(lq/c\(rq - * command-line argument. - * On Unix/Linux, <command> is passed to the \(lq/bin/sh\(rq - * shell with the \(lq-c\(rq command-line argument. - * Therefore operating system restrictions on the maximum + * On DOS-like systems like Windows, <command> is passed to + * 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 + * specified by the \fB$SHELL\fP environment variable + * with the \(lq-c\(rq command-line argument. + * Therefore the default shell can be configured using + * the corresponding environment registers. + * The operating system restrictions on the maximum * length of command-line arguments apply to <command> and * quoting of parameters within <command> is somewhat platform * dependent. @@ -191,10 +202,10 @@ parse_shell_command_line(const gchar *cmdline, GError **error) * <command> just as an UNIX98 \(lq/bin/sh\(rq would, but without * performing any expansions. * The program specified in <command> is searched for in - * standard locations (according to the \(lqPATH\(rq environment + * standard locations (according to the \fB$PATH\fP environment * variable). - * This mode of operation can also be enforced on Windows and - * Unix by enabling bit 7 in the ED flag, e.g. by executing + * This mode of operation can also be enforced on all platforms + * by enabling bit 7 in the ED flag, e.g. by executing * \(lq0,128ED\(rq, and is recommended when writing cross-platform * macros using the EC command. * |