aboutsummaryrefslogtreecommitdiffstats
path: root/src/w32proc.c
diff options
context:
space:
mode:
authorRichard M. Stallman1996-05-10 20:29:43 +0000
committerRichard M. Stallman1996-05-10 20:29:43 +0000
commit93fdf2f820a0e401a117bf9e29299ebcd19a7ddf (patch)
treeeb86bda4f30cbb93a7715b0a6cd2a8ddf6c65791 /src/w32proc.c
parentff38b715722c80d6ea06cd3bbf4abc327a67aaac (diff)
downloademacs-93fdf2f820a0e401a117bf9e29299ebcd19a7ddf.tar.gz
emacs-93fdf2f820a0e401a117bf9e29299ebcd19a7ddf.zip
(Vwin32_quote_process_args): New variable.
(sys_spawnve): If Vwin32_quote_process_args, quote the args. (syms_of_ntproc): Set up Lisp variable.
Diffstat (limited to 'src/w32proc.c')
-rw-r--r--src/w32proc.c43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/w32proc.c b/src/w32proc.c
index ee0f5f7986b..42b5b6729f8 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -45,6 +45,12 @@ Boston, MA 02111-1307, USA.
45#include "syswait.h" 45#include "syswait.h"
46#include "process.h" 46#include "process.h"
47 47
48/* Control whether spawnve quotes arguments as necessary to ensure
49 correct parsing by child process. Because not all uses of spawnve
50 are careful about constructing argv arrays, we make this behaviour
51 conditional (off by default). */
52Lisp_Object Vwin32_quote_process_args;
53
48#ifndef SYS_SIGLIST_DECLARED 54#ifndef SYS_SIGLIST_DECLARED
49extern char *sys_siglist[]; 55extern char *sys_siglist[];
50#endif 56#endif
@@ -595,16 +601,18 @@ sys_spawnve (int mode, char *cmdname, char **argv, char **envp)
595 601
596 if (*p == 0) 602 if (*p == 0)
597 add_quotes = 1; 603 add_quotes = 1;
598#if 0 604
599 /* Unfortunately, this causes more problems than it solves, 605 if (!NILP (Vwin32_quote_process_args))
600 because argv arrays are not always carefully constructed. 606 {
601 grep, for instance, passes the whole command line as one 607 /* This is conditional because it sometimes causes more
602 argument, so it becomes impossible to pass a regexp which 608 problems than it solves, since argv arrays are not always
603 contains spaces. */ 609 carefully constructed. M-x grep, for instance, passes the
604 for ( ; *p; p++) 610 whole command line as one argument, so it becomes
605 if (*p == ' ' || *p == '\t' || *p == '"') 611 impossible to pass a regexp which contains spaces. */
606 add_quotes = 1; 612 for ( ; *p; p++)
607#endif 613 if (*p == ' ' || *p == '\t' || *p == '"')
614 add_quotes = 1;
615 }
608 if (add_quotes) 616 if (add_quotes)
609 { 617 {
610 char * first; 618 char * first;
@@ -1064,4 +1072,19 @@ reset_standard_handles (int in, int out, int err, HANDLE handles[3])
1064 SetStdHandle (STD_ERROR_HANDLE, handles[2]); 1072 SetStdHandle (STD_ERROR_HANDLE, handles[2]);
1065} 1073}
1066 1074
1075
1076syms_of_ntproc ()
1077{
1078 DEFVAR_LISP ("win32-quote-process-args", &Vwin32_quote_process_args,
1079 "Non-nil enables quoting of process arguments to ensure correct parsing.\n\
1080Because Windows does not directly pass argv arrays to child processes,\n\
1081programs have to reconstruct the argv array by parsing the command\n\
1082line string. For an argument to contain a space, it must be enclosed\n\
1083in double quotes or it will be parsed as multiple arguments.\n\
1084\n\
1085However, the argument list to call-process is not always correctly\n\
1086constructed (or arguments have already been quoted), so enabling this\n\
1087option may cause unexpected behavior.");
1088 Vwin32_quote_process_args = Qnil;
1089}
1067/* end of ntproc.c */ 1090/* end of ntproc.c */