]> Cypherpunks repositories - gostls13.git/commit
cmd/go: improve handling of os.DevNull on Windows
authorDamien Neil <dneil@google.com>
Wed, 9 Nov 2022 17:42:04 +0000 (09:42 -0800)
committerDamien Neil <dneil@google.com>
Wed, 9 Nov 2022 22:05:51 +0000 (22:05 +0000)
commit575964d42c7b3001c09f2676d0ee9d520debb5eb
tree25f50f9ddea01013d729ecdd5f41643fbaafaad1
parent0521a12401887a0e84c1c913d1af50c647efaf8b
cmd/go: improve handling of os.DevNull on Windows

The "go test" and "go build" commands have special-case behavior when
passed "-o /dev/null". These checks are case-sensitive and assume that
os.DevNull is an absolute path. Windows filesystems are case-insensitive
and os.DevNull is NUL, which is not an absolute path.

CL 145220 changed filepath.IsAbs to report "NUL" as absolute to work
around this issue; that change is being rolled back and a better fix here
is to compare the value of -o against os.DevNull before attempting to
merge it with a base path. Make that fix.

On Windows, accept any capitilization of "NUL" as the null device.

This change doesn't cover every possible name for the null device, such
as "-o //./NUL", but this test is for efficiency rather than correctness.
Accepting just the most common name is fine.

For #56217.

Change-Id: I60b59b671789fc456074d3c8bc755a74ea8d5765
Reviewed-on: https://go-review.googlesource.com/c/go/+/449117
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
src/cmd/go/internal/base/path.go
src/cmd/go/internal/test/test.go
src/cmd/go/internal/work/build.go