golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.85k stars 17.65k forks source link

cmd/go/internal/envcmd: double check plan 9 behavior in PrintEnv when null byte present in value #59979

Open matloob opened 1 year ago

matloob commented 1 year ago

We'd like a plan 9 expert to double check this: In PrintEnv in cmd/go/internal/envcmd/env.go, plan9's handling behavior is different based on whether there's a null byte. If there's not a null byte present it quotes the string, and if there isn't it puts them in a parenthesized list, but doesn't quote each of the listed strings. We want to make sure that not quoting each of the strings in the list is the intended behavior.

bcmills commented 1 year ago

This is in the context of https://go.dev/cl/488375 / #58508.

(attn @golang/plan9)

millerresearch commented 1 year ago

In practice only GOPATH is likely to have a list value, and if a Plan 9 directory name in the path needed quoting it would likely cause all sorts of pain. But in theory one could have, for example, a directory with spaces in its name (imported from another OS?) and failing to quote it would mean that the output from go env could not safely be executed in the shell to assign GOPATH correctly.

Therefore my opinion is that the elements of a list should be individually quoted.

bcmills commented 1 year ago

I suspect that Russ is the only person on the Go team familiar enough with the Plan 9 shell to implement quoting, but if someone wants to contribute a fix once CL 488375 is merged I'd be glad to review it.

millerresearch commented 1 year ago

if someone wants to contribute a fix once CL 488375 is merged I'd be glad to review it.

I'll do it.