-
Notifications
You must be signed in to change notification settings - Fork 18k
os/exec: environment variable de-duplication breaks old behaviour #19877
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
Comments
I would also think that the latest duplicate would be kept. Perhaps worth noting that elsewhere in the standard library, we keep the first of the duplicates, such as in url parameters or http headers.
Could you elaborate on how bash behaves? Or do you mean the following?
For the sake of completeness, both |
@mvdan Change |
I don't understand - the |
When you use your shell,
The shell is stripping all but the last pair and only running Observe (on Linux): package main
import (
"fmt"
"io/ioutil"
"log"
"os"
)
func main() {
slurp, err := ioutil.ReadFile("/proc/self/environ")
if err != nil {
log.Fatal(err)
}
fmt.Printf("%q\n", slurp)
fmt.Printf("%q\n", os.Getenv("xxx"))
}
So at tip, Go is now doing what shells are doing. Go doesn't have the option of making We probably should've done this from day 1. Sorry. My fault. I never knew about shells doing this until recently. I think the best option, @rogpeppe, is to update your tests. None of this was documented or guaranteed in the past, neither in Go nor in shell or C, AFAIK. |
I agree it's a bug fix and should stay. |
This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background.
This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background.
add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background.
This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background.
This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background.
? rebase rebase Change the series name to align with other distros corrected series ID Added support to Zypper added lsb-release as default package typo in zypper name test fails rebase adding debug info missing line solved remove debug Export proxy settings as systemd config AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file rebase Added support to Zypper typo in zypper name adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Corrected fails in test Change the series name to align with other distros corrected series ID Added support to Zypper typo in zypper name test fails adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file
? rebase rebase Change the series name to align with other distros corrected series ID Added support to Zypper added lsb-release as default package typo in zypper name test fails rebase adding debug info missing line solved remove debug Export proxy settings as systemd config AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file rebase Added support to Zypper typo in zypper name adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Corrected fails in test Change the series name to align with other distros corrected series ID Added support to Zypper typo in zypper name test fails adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix make Setenv ignore malformed entries rather than panic now it is ok
This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background.
? rebase rebase Change the series name to align with other distros corrected series ID Added support to Zypper added lsb-release as default package typo in zypper name test fails rebase adding debug info missing line solved remove debug Export proxy settings as systemd config AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file rebase Added support to Zypper typo in zypper name adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Corrected fails in test Change the series name to align with other distros corrected series ID Added support to Zypper typo in zypper name test fails adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix make Setenv ignore malformed entries rather than panic now it is ok AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic OpenSUSE support in utils/os ? rebase rebase Change the series name to align with other distros corrected series ID Added support to Zypper added lsb-release as default package typo in zypper name test fails rebase adding debug info missing line solved remove debug Export proxy settings as systemd config AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file rebase Added support to Zypper typo in zypper name adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Corrected fails in test Change the series name to align with other distros corrected series ID Added support to Zypper typo in zypper name test fails adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix make Setenv ignore malformed entries rather than panic now it is ok AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic
? rebase rebase Change the series name to align with other distros corrected series ID Added support to Zypper added lsb-release as default package typo in zypper name test fails rebase adding debug info missing line solved remove debug Export proxy settings as systemd config AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file rebase Added support to Zypper typo in zypper name adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Corrected fails in test Change the series name to align with other distros corrected series ID Added support to Zypper typo in zypper name test fails adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix make Setenv ignore malformed entries rather than panic now it is ok AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic OpenSUSE support in utils/os ? rebase rebase Change the series name to align with other distros corrected series ID Added support to Zypper added lsb-release as default package typo in zypper name test fails rebase adding debug info missing line solved remove debug Export proxy settings as systemd config AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file rebase Added support to Zypper typo in zypper name adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Corrected fails in test Change the series name to align with other distros corrected series ID Added support to Zypper typo in zypper name test fails adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix make Setenv ignore malformed entries rather than panic now it is ok AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix make Setenv ignore malformed entries rather than panic
? rebase rebase Change the series name to align with other distros corrected series ID Added support to Zypper added lsb-release as default package typo in zypper name test fails rebase adding debug info missing line solved remove debug Export proxy settings as systemd config AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file rebase Added support to Zypper typo in zypper name adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Corrected fails in test Change the series name to align with other distros corrected series ID Added support to Zypper typo in zypper name test fails adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix make Setenv ignore malformed entries rather than panic now it is ok AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic OpenSUSE support in utils/os ? rebase rebase Change the series name to align with other distros corrected series ID Added support to Zypper added lsb-release as default package typo in zypper name test fails rebase adding debug info missing line solved remove debug Export proxy settings as systemd config AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file rebase Added support to Zypper typo in zypper name adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic Updating PR with the first comments Corrected fails in test Change the series name to align with other distros corrected series ID Added support to Zypper typo in zypper name test fails adding debug info missing line solved remove debug AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix solved zypper interactive bug add test make Setenv ignore malformed entries rather than panic Updating PR with the first comments Updated copyright of testing file AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix make Setenv ignore malformed entries rather than panic now it is ok AddNoProxyAddress Add separate AutoNoProxyList add Setenv function This makes it easier to override environment variables since just appending environment variables doesn't work any more (and never did for non-Go programs). See golang/go#19877 for background. make Setenv ignore malformed entries rather than panic AddNoProxyAddress Add separate AutoNoProxyList Document AUtoNoProxy, add newline at the end of ScriptEnvironment and EnvironmentValues test fix make Setenv ignore malformed entries rather than panic
go version devel +2bd6360 Wed Mar 8 03:24:44 2017 +0000 linux/amd64
The change reviewed in https://go-review.googlesource.com/c/37586/
has broken some of our tests because Go's behaviour when
importing environment variables is to use the first instance
of the variable, not the last (unlike bash, for example), so
when some code that appends a duplicate variable to the
environment and then executes a Go program, the
variable seen by the program is now the last value
where before it was the first.
To demonstrate the issue, build the following two programs:
second program:
Try running tst2 with different versions of Go. I'd expect to see "x=b" in both cases
but old versions of Go print "x=a" instead.
The text was updated successfully, but these errors were encountered: