comparison src/msdos.c @ 30529:788ce16426e3

(run_msdos_command): Save and restore the master environment, for the case that child_setup signals an error. When mirroring slashes in DOS shell commands, don't fail if argv[2] has embedded blanks.
author Eli Zaretskii <eliz@gnu.org>
date Mon, 31 Jul 2000 06:24:21 +0000
parents ace34a073127
children 328993ad6017
comparison
equal deleted inserted replaced
30528:01b106cfeb80 30529:788ce16426e3
4649 if (msshell) 4649 if (msshell)
4650 { 4650 {
4651 saveargv1 = argv[1]; 4651 saveargv1 = argv[1];
4652 saveargv2 = argv[2]; 4652 saveargv2 = argv[2];
4653 argv[1] = "/c"; 4653 argv[1] = "/c";
4654 if (argv[2]) 4654 /* We only need to mirror slashes if a DOS shell will be invoked
4655 not via `system' (which does the mirroring itself). Yes, that
4656 means DJGPP v1.x will lose here. */
4657 if (argv[2] && argv[3])
4655 { 4658 {
4656 char *p = alloca (strlen (argv[2]) + 1); 4659 char *p = alloca (strlen (argv[2]) + 1);
4657 4660
4658 strcpy (argv[2] = p, saveargv2); 4661 strcpy (argv[2] = p, saveargv2);
4659 while (*p && isspace (*p)) 4662 while (*p && isspace (*p))
4660 p++; 4663 p++;
4661 while (*p && !isspace (*p)) 4664 while (*p)
4662 if (*p == '/') 4665 {
4663 *p++ = '\\'; 4666 if (*p == '/')
4664 else 4667 *p++ = '\\';
4665 p++; 4668 else
4669 p++;
4670 }
4666 } 4671 }
4667 } 4672 }
4668 4673
4669 chdir (working_dir); 4674 chdir (working_dir);
4670 inbak = dup (0); 4675 inbak = dup (0);
4701 for (cmnd = saveargv2; *cmnd && isspace (*cmnd); cmnd++) 4706 for (cmnd = saveargv2; *cmnd && isspace (*cmnd); cmnd++)
4702 ; 4707 ;
4703 if (*cmnd) 4708 if (*cmnd)
4704 { 4709 {
4705 extern char **environ; 4710 extern char **environ;
4711 char **save_env = environ;
4706 int save_system_flags = __system_flags; 4712 int save_system_flags = __system_flags;
4707 4713
4708 /* Request the most powerful version of `system'. We need 4714 /* Request the most powerful version of `system'. We need
4709 all the help we can get to avoid calling stock DOS shells. */ 4715 all the help we can get to avoid calling stock DOS shells. */
4710 __system_flags = (__system_redirect 4716 __system_flags = (__system_redirect
4715 | __system_emulate_chdir); 4721 | __system_emulate_chdir);
4716 4722
4717 environ = envv; 4723 environ = envv;
4718 result = system (cmnd); 4724 result = system (cmnd);
4719 __system_flags = save_system_flags; 4725 __system_flags = save_system_flags;
4726 environ = save_env;
4720 } 4727 }
4721 else 4728 else
4722 result = 0; /* emulate Unixy shell behavior with empty cmd line */ 4729 result = 0; /* emulate Unixy shell behavior with empty cmd line */
4723 } 4730 }
4724 else 4731 else