mirror of
https://github.com/golang/go
synced 2024-11-21 21:14:47 -07:00
cmd/dist: prevent race on VERSION creation
Commands such as "dist version > VERSION" will cause the shell to create an empty VERSION file and set dist's stdout to its fd. dist in turn looks at VERSION and uses its content if available, which is empty at this point. Fix that by ignoring VERSION if it's empty. Also prevent cmdversion from running findgoversion a second time. It was already loaded by init. R=adg, gustavo, rsc CC=golang-dev https://golang.org/cl/5639044
This commit is contained in:
parent
4151183e94
commit
c2fe6634db
7
src/cmd/dist/build.c
vendored
7
src/cmd/dist/build.c
vendored
@ -179,6 +179,11 @@ findgoversion(void)
|
||||
if(isfile(bstr(&path))) {
|
||||
readfile(&b, bstr(&path));
|
||||
chomp(&b);
|
||||
// Commands such as "dist version > VERSION" will cause
|
||||
// the shell to create an empty VERSION file and set dist's
|
||||
// stdout to its fd. dist in turn looks at VERSION and uses
|
||||
// its content if available, which is empty at this point.
|
||||
if(b.len > 0)
|
||||
goto done;
|
||||
}
|
||||
|
||||
@ -1370,5 +1375,5 @@ cmdversion(int argc, char **argv)
|
||||
if(argc > 0)
|
||||
usage();
|
||||
|
||||
xprintf("%s\n", findgoversion());
|
||||
xprintf("%s\n", goversion);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user