0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

updated for version 7.3.203

Problem:    MS-Windows: Can't run an external command without a console window.
Solution:   Support ":!start /b cmd". (Xaizek)
This commit is contained in:
Bram Moolenaar
2011-05-25 17:06:22 +02:00
parent ed38b0ac41
commit bd8608d979
3 changed files with 55 additions and 2 deletions

View File

@@ -3401,6 +3401,7 @@ mch_call_shell(
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
DWORD flags = CREATE_NEW_CONSOLE;
si.cb = sizeof(si);
si.lpReserved = NULL;
@@ -3418,6 +3419,22 @@ mch_call_shell(
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWMINNOACTIVE;
}
else if ((STRNICMP(cmdbase, "/b", 2) == 0)
&& vim_iswhite(cmdbase[2]))
{
cmdbase = skipwhite(cmdbase + 2);
flags = CREATE_NO_WINDOW;
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdInput = CreateFile("\\\\.\\NUL", // File name
GENERIC_READ, // Access flags
0, // Share flags
NULL, // Security att.
OPEN_EXISTING, // Open flags
FILE_ATTRIBUTE_NORMAL, // File att.
NULL); // Temp file
si.hStdOutput = si.hStdInput;
si.hStdError = si.hStdInput;
}
/* When the command is in double quotes, but 'shellxquote' is
* empty, keep the double quotes around the command.
@@ -3445,7 +3462,7 @@ mch_call_shell(
NULL, // Process security attributes
NULL, // Thread security attributes
FALSE, // Inherit handles
CREATE_NEW_CONSOLE, // Creation flags
flags, // Creation flags
NULL, // Environment
NULL, // Current directory
&si, // Startup information
@@ -3458,6 +3475,11 @@ mch_call_shell(
EMSG(_("E371: Command not found"));
#endif
}
if (si.hStdInput != NULL)
{
/* Close the handle to \\.\NUL */
CloseHandle(si.hStdInput);
}
/* Close the handles to the subprocess, so that it goes away */
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);