]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/go: sanitize go env outputs
authorMichael Matloob <matloob@golang.org>
Mon, 24 Apr 2023 20:57:28 +0000 (16:57 -0400)
committerMichael Matloob <matloob@golang.org>
Fri, 5 May 2023 14:28:38 +0000 (14:28 +0000)
commitf379e78951a405e7e99a60fb231eeedbf976c108
treecefba0f27dd213674968f1001b59a79cf4fae287
parentfe10464358057778732e9c958683039beb64e61a
cmd/go: sanitize go env outputs

go env, without any arguments, outputs the environment variables in
the form of a script that can be run on the host OS. On Unix, single
quote the strings and place single quotes themselves outside the
single quoted strings. On windows use the set "var=val" syntax with
the quote starting before the variable.

Fixes #58508

Change-Id: Iecd379a4af7285ea9b2024f0202250c74fd9a2bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/488375
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
src/cmd/go/internal/envcmd/env.go
src/cmd/go/internal/envcmd/env_test.go [new file with mode: 0644]
src/cmd/go/testdata/script/env_sanitize.txt [new file with mode: 0644]
src/cmd/go/testdata/script/work_env.txt