--- origsrc/cygwin-run/src/run.1.in 2015-05-14 17:23:26.000000000 +0200 +++ src/cygwin-run/src/run.1.in 2015-05-15 10:15:44.265625000 +0200 @@ -4,10 +4,10 @@ run - start programs with hidden console .SH SYNOPSIS .B run -[ -p path ] command [ -wait ] [ -quote ] arguments +[ -p path ] command [ -wait ] [ --quote ] [--run-nogui] [--run-notty] [--run-debug[=N]] [--run-verbose] arguments .B runcommand -[ -p path ] [ -wait ] [ -quote ] arguments +[ -p path ] [ -wait ] [ --quote ] [--run-nogui] [--run-notty] [--run-debug[=N]] [--run-verbose] arguments .SH DESCRIPTION Windows programs are either GUI programs or console programs. When started @@ -32,7 +32,7 @@ as first program argument will make wait for program completition, otherwise it returns immediately. The -.B -quote +.B --quote option enables automatic quoting of arguments with embedded whitespace, double quotes or backslashes for consumption by the standard Microsoft startup code or compatible implementations. If you @@ -47,6 +47,26 @@ The second variant is for creating wrap .I run will try to start the program (eg emacs). +.SH OPTIONS +.TP +\fB\-w\fR|\-\-wait +wait for the target app to complete before returning +.TP +\fB\-\-run\-nogui\fR +disable informational popups +.TP +\fB\-\-run\-notty\fR +disable stderr messages +.TP +\fB\-\-run\-verbose\fR +allow error, warning, and info messages +.TP +\fB\-\-run\-debug\fR[=\fIN\fR] +turn on debugging messages, as well as +those enabled by \fB\-\-verbose\fR. N defaults to 1 +\fB\-\-run\-debug\fR=\fI0\fR is the same as \fB\-\-run\-verbose\fR. Values +higher than 1 enable increasing details + .SH EXAMPLES run -p /usr/X11R6/bin xterm --- origsrc/cygwin-run/src/run.c 2015-05-14 17:23:26.000000000 +0200 +++ src/cygwin-run/src/run.c 2015-05-15 10:15:44.296875000 +0200 @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -221,7 +222,7 @@ realMain(int argc, char* argv[]) opt_loglevel = RUN2_DEFAULT_LOG_LEVEL; # endif - setlocale(LC_ALL, "C"); + setlocale(LC_ALL, ""); #endif /* allow error messages during option parsing */ @@ -337,6 +338,7 @@ realMain(int argc, char* argv[]) PROCESS_INFORMATION child; JOBOBJECT_BASIC_LIMIT_INFORMATION jobinfo; DWORD create_flags = 0; + wchar_t lpCommandLine[MAX_ARGS * MAX_PATH]; debugMsg (1, "Launch GUI target, async: %s", cmdline2); ZeroMemory( &child, sizeof(PROCESS_INFORMATION) ); @@ -349,8 +351,11 @@ realMain(int argc, char* argv[]) | JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK))) create_flags |= CREATE_BREAKAWAY_FROM_JOB; - dwRetCode = CreateProcess (NULL, - cmdline2,/* command line */ + mbstowcs(lpCommandLine, cmdline2, sizeof (lpCommandLine)); + debugMsg (1, "converted command-line: %ls, length %u, size %u", lpCommandLine, + wcslen (lpCommandLine), sizeof (lpCommandLine)); + dwRetCode = CreateProcessW (NULL, + lpCommandLine, /* command line */ NULL, /* process security attributes */ NULL, /* primary thread security attributes */ FALSE, /* handles are NOT inherited, */ @@ -396,13 +401,13 @@ xemacs_special(char* exec) char tmp[MAX_PATH + FILENAME_MAX + 100]; strcpy(exec2,exec); /* this depends on short-circuit evaluation */ - if ( ((p = strrchr(exec2,'\\')) && stricmp(p,"\\xemacs") == 0) || - ((p = strrchr(exec2,'/')) && stricmp(p,"/xemacs") == 0) || - ((p = strrchr(exec2,'\\')) && stricmp(p,"\\xemacs.exe") == 0) || - ((p = strrchr(exec2,'/')) && stricmp(p,"/xemacs.exe") == 0) ) + if ( ((p = strrchr(exec2,'\\')) && strcasecmp(p,"\\xemacs") == 0) || + ((p = strrchr(exec2,'/')) && strcasecmp(p,"/xemacs") == 0) || + ((p = strrchr(exec2,'\\')) && strcasecmp(p,"\\xemacs.exe") == 0) || + ((p = strrchr(exec2,'/')) && strcasecmp(p,"/xemacs.exe") == 0) ) { - if ( ((p2 = strrchr(p, '\\')) && stricmp(p2, "\\bin") == 0) || - ((p2 = strrchr(p, '/')) && stricmp(p2, "/bin") == 0) ) + if ( ((p2 = strrchr(p, '\\')) && strcasecmp(p2, "\\bin") == 0) || + ((p2 = strrchr(p, '/')) && strcasecmp(p2, "/bin") == 0) ) { *p2 = '\0'; #if defined(__CYGWIN__) @@ -438,7 +443,7 @@ parse_args(int *argc, char* argv[]) * leaving the rest for the target app * * look for "-p ARG" and remove from arg vector - * ditto: -wait, --run-nogui, --run-notty, --run-debug[=N] and + * ditto: -wait, --quote, --run-nogui, --run-notty, --run-debug[=N] and * --run-verbose */ for (i = 1; i < *argc; i++) --- origsrc/cygwin-run/src/run2_gpl.c 2015-05-14 17:23:26.000000000 +0200 +++ src/cygwin-run/src/run2_gpl.c 2015-05-15 10:15:44.328125000 +0200 @@ -46,6 +46,7 @@ # include # include # include +# include # include #endif @@ -322,6 +323,8 @@ run2_start_child (char *cmdline, char *s DWORD os_version; JOBOBJECT_BASIC_LIMIT_INFORMATION jobinfo; DWORD create_flags = 0; + wchar_t lpCommandLine[(cmdline ? strlen (cmdline): 0) + 1]; + wchar_t lpCurrentDirectory[(startin ? strlen (startin) : 0) + 1]; run2_setup_win_environ (); bHaveConsole = run2_have_console (); @@ -382,14 +385,27 @@ run2_start_child (char *cmdline, char *s | JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK))) create_flags |= CREATE_BREAKAWAY_FROM_JOB; - bFuncReturn = CreateProcess (NULL, /* LPCTSTR lpApplicationName */ - cmdline, /* LPTSTR lpCommandLine */ + if (cmdline) + { + mbstowcs(lpCommandLine, cmdline, sizeof (lpCommandLine)); + debugMsg (1, "converted command-line: %ls, length %u, size %u", lpCommandLine, + wcslen (lpCommandLine), sizeof (lpCommandLine)/sizeof (wchar_t)); + } + if (startin) + { + mbstowcs(lpCurrentDirectory, startin, sizeof (lpCurrentDirectory)); + debugMsg (1, "converted current-directory: %ls, length %u, size %u", + lpCurrentDirectory, wcslen (lpCurrentDirectory), + sizeof (lpCurrentDirectory)/sizeof (wchar_t)); + } + bFuncReturn = CreateProcessW (NULL, /* LPCTSTR lpApplicationName */ + (cmdline ? lpCommandLine : NULL), /* LPTSTR lpCommandLine */ &sec_attrs, /* LPSECURITY_ATTRIBUTES lpProcessAttributes */ NULL, /* LPSECURITY_ATTRIBUTES lpThreadAttributes */ TRUE, /* BOOL bInheritHandles */ create_flags, /* DWORD dwCreationFlags */ NULL, /* LPVOID lpEnvironment (use parent's env) */ - startin, /* LPCTSTR lpCurrentDirectory */ + (startin ? lpCurrentDirectory : NULL), /* LPCTSTR lpCurrentDirectory */ &start, /* LPSTARTUPINFO lpStartupInfo */ &child); /* LPPROCESS_INFORMATION lpProcessInformation */ --- origsrc/cygwin-run/src/util.c 2015-05-14 17:23:26.000000000 +0200 +++ src/cygwin-run/src/util.c 2015-05-15 10:15:44.359375000 +0200 @@ -125,7 +125,7 @@ run2_ends_with(const char* s1, const cha len1 = strlen(s1); len2 = strlen(s2); if (len1 - len2 >= 0) - if (stricmp(&(s1[len1-len2]),s2) == 0) + if (strcasecmp(&(s1[len1-len2]),s2) == 0) retval = 1; return retval; } @@ -136,7 +136,7 @@ run2_strip_exe(char* s) size_t slen = strlen(s); if ((slen > 4) && /* long enough to have .exe extension */ /* second part not evaluated (short circuit) if exec_arg too short */ - (stricmp(&(s[slen-4]),".exe") == 0)) + (strcasecmp(&(s[slen-4]),".exe") == 0)) s[slen-4] = '\0'; } @@ -551,7 +551,7 @@ run2_quote_strdup (const char *s, int qu d[j++] = '\0'; return d; } - return run2_strdup (s); + return run2_strdup (len ? s : "\"\""); } char *