Skip to content
Snippets Groups Projects
Commit a01c2055 authored by rswindell's avatar rswindell
Browse files

Changed EX_CC to EX_SH.

Win32 external() now uses the comspec if the EX_SH mode bit is set.
Unix external() now supports the EX_SH mode bit and auto-redirection detection.
parent f6151038
No related branches found
No related tags found
No related merge requests found
......@@ -265,7 +265,7 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
if(i<cfg.total_natvpgms || mode&EX_NATIVE)
native=true;
if(strcspn(cmdline,"<>|")!=strlen(cmdline))
if(mode&EX_SH || strcspn(cmdline,"<>|")!=strlen(cmdline))
sprintf(comspec_str,"%s /C ", comspec);
else
comspec_str[0]=0;
......@@ -799,6 +799,8 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
{
char str[256];
char fname[128];
char shell_str[MAX_PATH];
char fullcmdline[MAX_PATH*2];
char* argv[30];
char* p;
BYTE* bp;
......@@ -842,6 +844,12 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
return(-1);
}
if(mode&EX_SH || strcspn(cmdline,"<>|")!=strlen(cmdline))
sprintf(shell_str,"%s -c ", comspec);
else
shell_str[0]=0;
sprintf(fullcmdline,"%s%s",shell_str,cmdline);
if(native) { // Native (32-bit) external
// Current environment passed to child process
......@@ -874,7 +882,7 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
if((pid=fork())==-1) {
pthread_mutex_unlock(&input_thread_mutex);
errormsg(WHERE,ERR_EXEC,cmdline,0);
errormsg(WHERE,ERR_EXEC,fullcmdline,0);
return(-1);
}
......@@ -882,14 +890,14 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
if(startup_dir!=NULL && startup_dir[0])
chdir(startup_dir);
lprintf("Node %d executing external: %s",cfg.node_num,cmdline);
lprintf("Node %d executing external: %s",cfg.node_num,fullcmdline);
argv[0]=cmdline; /* point to the beginning of the string */
argv[0]=fullcmdline; /* point to the beginning of the string */
argc=1;
for(i=0;cmdline[i];i++) /* Break up command line */
if(cmdline[i]==SP) {
cmdline[i]=0; /* insert nulls */
argv[argc++]=cmdline+i+1; /* point to the beginning of the next arg */
for(i=0;fullcmdline[i];i++) /* Break up command line */
if(fullcmdline[i]==SP) {
fullcmdline[i]=0; /* insert nulls */
argv[argc++]=fullcmdline+i+1; /* point to the beginning of the next arg */
}
argv[argc]=0;
......@@ -907,7 +915,7 @@ int sbbs_t::external(char* cmdline, long mode, char* startup_dir)
}
execvp(argv[0],argv);
errormsg(WHERE,ERR_EXEC,cmdline,0);
errormsg(WHERE,ERR_EXEC,fullcmdline,0);
exit(-1); /* should never get here */
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment