Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go env incorrect quoting for values with double quotes #58855

Closed
seankhliao opened this issue Mar 3, 2023 · 5 comments
Closed

cmd/go: go env incorrect quoting for values with double quotes #58855

seankhliao opened this issue Mar 3, 2023 · 5 comments
Labels
GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@seankhliao
Copy link
Member

What version of Go are you using (go version)?

» go version                  
go version devel go1.21-b35ee3b0467 Wed Mar 1 14:25:13 2023 +0000 linux/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
» go env       
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS="-trimpath "-ldflags=-s -w""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/user/.data/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/user/.data/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/user/sdk/gotip"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/user/sdk/gotip/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.21-b35ee3b0467 Wed Mar 1 14:25:13 2023 +0000"
GCCGO="gccgo"
GOAMD64="v3"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build547532058=/tmp/go-build -gno-record-gcc-switches"

What did you do?

» go env -w GOFLAGS='-trimpath "-ldflags=-s -w"'

» go env | grep GOFLAGS                         
GOFLAGS="-trimpath "-ldflags=-s -w""

What did you expect to see?

GOFLAGS='-trimpath "-ldflags=-s -w"'

or

GOFLAGS="-trimpath \"-ldflags=-s -w\""

What did you see instead?

incorrect quoting of values with double quotes

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels Mar 3, 2023
@seankhliao
Copy link
Member Author

cc @bcmills @matloob

@bcmills
Copy link
Contributor

bcmills commented Mar 3, 2023

Yep, that's wrong. 😩

The bug is here:
https://cs.opensource.google/go/go/+/master:src/cmd/go/internal/envcmd/env.go;l=418;drc=db259cdd80eff527e8f344d678031c516167d258

We have a quoted.Join function that is used elsewhere in envcmd/env.go. It should probably be used in PrintEnv as well.

@bcmills bcmills added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Mar 3, 2023
@bcmills bcmills added this to the Backlog milestone Mar 3, 2023
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Mar 3, 2023
@cuishuang
Copy link
Contributor

If you don't mind, I'd like to fix this bug.

@gopherbot
Copy link

Change https://go.dev/cl/473895 mentions this issue: cmd/go: fix incorrect quoting for values with double quotes

@seankhliao
Copy link
Member Author

Fixed in CL 488375

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants