aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--win32/popen.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/win32/popen.c b/win32/popen.c
index 6b8e52ca9..59f5ca9f0 100644
--- a/win32/popen.c
+++ b/win32/popen.c
@@ -1,5 +1,6 @@
1#include <fcntl.h> 1#include <fcntl.h>
2#include "libbb.h" 2#include "libbb.h"
3#include "NUM_APPLETS.h"
3 4
4typedef struct { 5typedef struct {
5 PROCESS_INFORMATION piProcInfo; 6 PROCESS_INFORMATION piProcInfo;
@@ -90,13 +91,22 @@ FILE *mingw_popen(const char *cmd, const char *mode)
90 } 91 }
91 } 92 }
92 93
93 len = strlen(cmd) + 10 + count; 94 len = strlen(bb_busybox_exec_path) + strlen(cmd) + 32 + count;
94 if ( (cmd_buff=malloc(len)) == NULL ) { 95 if ( (cmd_buff=malloc(len)) == NULL ) {
95 return NULL; 96 return NULL;
96 } 97 }
97 98
99#if (ENABLE_FEATURE_PREFER_APPLETS || ENABLE_FEATURE_SH_STANDALONE) && \
100 NUM_APPLETS > 1
101 if (find_applet_by_name("sh") >= 0) {
102 strcpy(cmd_buff, bb_busybox_exec_path);
103 strcat(cmd_buff, " --busybox sh -c \"");
104 }
105 else
106#endif
107 strcpy(cmd_buff, "sh -c \"");
108
98 /* escape double quotes */ 109 /* escape double quotes */
99 strcpy(cmd_buff, "sh -c \"");
100 for ( s=cmd,t=cmd_buff+strlen(cmd_buff); *s; ++s ) { 110 for ( s=cmd,t=cmd_buff+strlen(cmd_buff); *s; ++s ) {
101 if ( *s == '"' ) { 111 if ( *s == '"' ) {
102 *t++ = '\\'; 112 *t++ = '\\';