changeset 21693:fc0153e88b71

(run_msdos_command): Don't construct process environment, it's already done in child_setup. (run_msdos_command): Add ENVV to argument list.
author Eli Zaretskii <eliz@gnu.org>
date Tue, 21 Apr 1998 11:10:56 +0000
parents 303a96060ff1
children 6e12eeda6913
files src/msdos.c
diffstat 1 files changed, 33 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/src/msdos.c	Tue Apr 21 06:14:05 1998 +0000
+++ b/src/msdos.c	Tue Apr 21 11:10:56 1998 +0000
@@ -3041,12 +3041,13 @@
    file TEMPOUT and stderr to TEMPERR.  */
 
 int
-run_msdos_command (argv, dir, tempin, tempout, temperr)
+run_msdos_command (argv, working_dir, tempin, tempout, temperr, envv)
      unsigned char **argv;
-     Lisp_Object dir;
+     const char *working_dir;
      int tempin, tempout, temperr;
+     char **envv;
 {
-  char *saveargv1, *saveargv2, **envv, *lowcase_argv0, *pa, *pl;
+  char *saveargv1, *saveargv2, *lowcase_argv0, *pa, *pl;
   char oldwd[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS.  */
   int msshell, result = -1;
   int inbak, outbak, errbak;
@@ -3091,29 +3092,7 @@
 	}
     }
 
-  /* Build the environment array.  */
-  {
-    extern Lisp_Object Vprocess_environment;
-    Lisp_Object tmp, lst;
-    int i, len;
-
-    lst = Vprocess_environment;
-    len = XFASTINT (Flength (lst));
-
-    envv = alloca ((len + 1) * sizeof (char *));
-    for (i = 0; i < len; i++)
-      {
-	tmp = Fcar (lst);
-	lst = Fcdr (lst);
-	CHECK_STRING (tmp, 0);
-	envv[i] = alloca (XSTRING (tmp)->size + 1);
-	strcpy (envv[i], XSTRING (tmp)->data);
-      }
-    envv[len] = (char *) 0;
-  }
-
-  if (STRINGP (dir))
-    chdir (XSTRING (dir)->data);
+  chdir (working_dir);
   inbak = dup (0);
   outbak = dup (1);
   errbak = dup (2);
@@ -3137,12 +3116,36 @@
 	 cannot grok commands longer than 126 characters.  In DJGPP v2
 	 and later, `system' is much smarter, so we'll call it instead.  */
 
-      extern char **environ;
-      environ = envv;
+      const char *cmnd;
 
       /* A shell gets a single argument--its full command
 	 line--whose original was saved in `saveargv2'.  */
-      result = system (saveargv2);
+
+      /* Don't let them pass empty command lines to `system', since
+	 with some shells it will try to invoke an interactive shell,
+	 which will hang Emacs.  */
+      for (cmnd = saveargv2; *cmnd && isspace (*cmnd); cmnd++)
+	;
+      if (*cmnd)
+	{
+	  extern char **environ;
+	  int save_system_flags = __system_flags;
+
+	  /* Request the most powerful version of `system'.  We need
+	     all the help we can get to avoid calling stock DOS shells.  */
+	  __system_flags =  (__system_redirect
+			     | __system_use_shell
+			     | __system_allow_multiple_cmds
+			     | __system_allow_long_cmds
+			     | __system_handle_null_commands
+			     | __system_emulate_chdir);
+
+	  environ = envv;
+	  result = system (cmnd);
+	  __system_flags = save_system_flags;
+	}
+      else
+	result = 0;	/* emulate Unixy shell behavior with empty cmd line */
     }
   else
 
@@ -3596,3 +3599,4 @@
 }
 
 #endif /* MSDOS */
+