mirror of
https://github.com/golang/go
synced 2024-11-19 18:54:41 -07:00
cmd/dist: don't fail when Mercurial is a batch file on Windows
On windows Mercurial installed with easy_install typically creates an hg.bat batch file in Python Scripts directory, which cannot be used with CreateProcess unless full path is specified. Work around by launching hg via cmd.exe /c. Additionally, fix a rare FormatMessageW crash. Fixes #3093. R=golang-dev, rsc, alex.brainman, aram, jdpoirier, mattn.jp CC=golang-dev https://golang.org/cl/5937043
This commit is contained in:
parent
f6d582db61
commit
0669261af1
6
src/cmd/dist/windows.c
vendored
6
src/cmd/dist/windows.c
vendored
@ -115,7 +115,7 @@ errstr(void)
|
|||||||
binit(&b);
|
binit(&b);
|
||||||
code = GetLastError();
|
code = GetLastError();
|
||||||
r = nil;
|
r = nil;
|
||||||
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||||
nil, code, 0, (Rune*)&r, 0, nil);
|
nil, code, 0, (Rune*)&r, 0, nil);
|
||||||
toutf(&b, r);
|
toutf(&b, r);
|
||||||
return bstr(&b); // leak but we're dying anyway
|
return bstr(&b); // leak but we're dying anyway
|
||||||
@ -285,9 +285,11 @@ genrun(Buf *b, char *dir, int mode, Vec *argv, int wait)
|
|||||||
binit(&cmd);
|
binit(&cmd);
|
||||||
|
|
||||||
for(i=0; i<argv->len; i++) {
|
for(i=0; i<argv->len; i++) {
|
||||||
|
q = argv->p[i];
|
||||||
|
if(i == 0 && streq(q, "hg"))
|
||||||
|
bwritestr(&cmd, "cmd.exe /c ");
|
||||||
if(i > 0)
|
if(i > 0)
|
||||||
bwritestr(&cmd, " ");
|
bwritestr(&cmd, " ");
|
||||||
q = argv->p[i];
|
|
||||||
if(contains(q, " ") || contains(q, "\t") || contains(q, "\"") || contains(q, "\\\\") || hassuffix(q, "\\")) {
|
if(contains(q, " ") || contains(q, "\t") || contains(q, "\"") || contains(q, "\\\\") || hassuffix(q, "\\")) {
|
||||||
bwritestr(&cmd, "\"");
|
bwritestr(&cmd, "\"");
|
||||||
nslash = 0;
|
nslash = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user