aboutsummaryrefslogtreecommitdiffstats
path: root/pc/popen.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2014-01-15 21:28:08 +0200
committerArnold D. Robbins <arnold@skeeve.com>2014-01-15 21:28:08 +0200
commit00db6f0be4e51725ab07db0e34164246bba57d16 (patch)
tree1d637f43f19d2aca485a615ed412d69169d4ac1d /pc/popen.c
parentf93264497cc50140921c05ead6626bb13bae38a9 (diff)
parent699b3a96bfcdd281b4f0db447fcf80ba7fbc6ec6 (diff)
downloadegawk-00db6f0be4e51725ab07db0e34164246bba57d16.tar.gz
egawk-00db6f0be4e51725ab07db0e34164246bba57d16.tar.bz2
egawk-00db6f0be4e51725ab07db0e34164246bba57d16.zip
Merge branch 'gawk-4.1-stable'
Diffstat (limited to 'pc/popen.c')
-rw-r--r--pc/popen.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/pc/popen.c b/pc/popen.c
index 399e250a..73770d98 100644
--- a/pc/popen.c
+++ b/pc/popen.c
@@ -13,7 +13,6 @@
#define _NFILE 40
#endif
-static char template[] = "piXXXXXX";
static struct {
char *command;
char *name;
@@ -34,6 +33,7 @@ static struct {
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#if 0
static int
unixshell(char *p)
{
@@ -119,20 +119,16 @@ unlink_and_free(char *cmd)
s = cmd;
unlink(s); free(cmd);
}
+#endif
int
os_system(const char *cmd)
{
- char *s;
- int i;
- char *cmd1;
+ char *cmdexe = getenv("ComSpec");
+ char *cmd1 = quote_cmd(cmd);
+ int i = spawnl(P_WAIT, cmdexe, "cmd.exe", "/c", cmd1, NULL);
- if ((cmd1 = scriptify(cmd)) == NULL) return(1);
- if (s = getenv("SHELL"))
- i = spawnlp(P_WAIT, s, s, cmd1 + strlen(s), NULL);
- else
- i = system(cmd1);
- unlink_and_free(cmd1);
+ free(cmd1);
return(i);
}
@@ -209,19 +205,15 @@ os_popen(const char *command, const char *mode )
char *name;
int cur;
char curmode[4];
-#if defined(__MINGW32__)
- char *cmd;
-#endif
if (*mode != 'r' && *mode != 'w')
return NULL;
strncpy(curmode, mode, 3); curmode[3] = '\0';
#if defined(__MINGW32__)
- current = popen(cmd = scriptify(command), mode);
+ current = popen(command, mode);
cur = fileno(current);
strcpy(pipes[cur].pmode, curmode);
- pipes[cur].command = cmd;
return(current);
#endif
@@ -268,7 +260,6 @@ os_pclose( FILE * current)
#if defined(__MINGW32__)
rval = pclose(current);
*pipes[cur].pmode = '\0';
- unlink_and_free(pipes[cur].command);
return rval;
#endif