diff options
author | Eli Zaretskii <eliz@gnu.org> | 2014-01-15 18:40:22 +0200 |
---|---|---|
committer | Eli Zaretskii <eliz@gnu.org> | 2014-01-15 18:40:22 +0200 |
commit | 9175c4e1b26dbdac5600df0b4d33717004c9a434 (patch) | |
tree | c87083166edd28d4ee449cfbdb8d031123f02606 | |
parent | c32da51ad91ff617b9e0ee60ed2ffd1baa8b0047 (diff) | |
download | egawk-9175c4e1b26dbdac5600df0b4d33717004c9a434.tar.gz egawk-9175c4e1b26dbdac5600df0b4d33717004c9a434.tar.bz2 egawk-9175c4e1b26dbdac5600df0b4d33717004c9a434.zip |
Make 'system' and pipe writes consistent with pipe reads on MinGW.
* popen.c (os_system): Use spawnl, and quote the command line, to
be consistent with what gawk_popen does.
(os_popen) [__MINGW32__]: Don't scriptify the command, to be
consistent with gawk_popen.
(os_pclose) [__MINGW32__]: Update to match os_open: no need to
unlink the script file.
-rw-r--r-- | pc/ChangeLog | 9 | ||||
-rw-r--r-- | pc/popen.c | 23 |
2 files changed, 16 insertions, 16 deletions
diff --git a/pc/ChangeLog b/pc/ChangeLog index eb5636e9..bd9c8c60 100644 --- a/pc/ChangeLog +++ b/pc/ChangeLog @@ -1,3 +1,12 @@ +2014-01-15 Eli Zaretskii <eliz@gnu.org> + + * popen.c (os_system): Use spawnl, and quote the command line, to + be consistent with what gawk_popen does. + (os_popen) [__MINGW32__]: Don't scriptify the command, to be + consistent with gawk_popen. + (os_pclose) [__MINGW32__]: Update to match os_open: no need to + unlink the script file. + 2013-12-10 Scott Deifik <scottd.mail@sbcglobal.net> * gawkmisc.c (init_sockets): Move into the right part of the @@ -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 |