aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/spawn.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2016-02-24 05:04:15 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2016-02-24 05:04:15 +0100
commit39124fd2ad6a3e0bf51d4b7c91fafef6108eacd5 (patch)
treefad2f09e7e22f21107ed18b43d9a53010d89d9ae /src/spawn.cpp
parent9f7f187f1860047c8cb24ca34552f31bf7a2c3ce (diff)
downloadsciteco-39124fd2ad6a3e0bf51d4b7c91fafef6108eacd5.tar.gz
EG and EC use $SHELL and $COMSPEC as the default command interpreters now
* The default command interpreter will thus be inherited from the operating system. In the case of UNIX from the user's passwd entry. E.g. if bash is used, bash extensions can be used immediately if flag 128 is not set in the ED flags. * On DOS-like systems there are also alternative interpreters (e.g. 4NT, 4OS2) that are configurable now. * At least on UNIX with $SHELL it is not guaranteed that the interpreter supports the standard command line arguments like "-c". If they don't, this will cause problems with EC. Since $SHELL is mapped to a Q-Register, it can however always be easily customized for SciTECO sessions in the user's .teco_ini.
Diffstat (limited to 'src/spawn.cpp')
-rw-r--r--src/spawn.cpp45
1 files changed, 28 insertions, 17 deletions
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.
*