Skip to content

Commit

Permalink
cli-plugins: PluginRunCommand: use cmd.Environ instead of os.Environ
Browse files Browse the repository at this point in the history
Commit 5011759 implemented a fix that
caused the current environment to be discarded, using `os.Environ()`.
On Windows, `os.Environ()` may produce an incorrect value for `PWD`,
for which a new function was added in go1.19;

- https://tip.golang.org/doc/go1.19#osexecpkgosexec
- https://go-review.googlesource.com/c/go/+/401340

Replace the use of `os.Environ()` with `cmd.Environ()` to address that.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Apr 25, 2024
1 parent 7f15dfa commit 5ccb484
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions cli-plugins/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ func PluginRunCommand(dockerCli command.Cli, name string, rootcmd *cobra.Command
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, ReexecEnvvar+"="+os.Args[0])
cmd.Env = append(cmd.Environ(), ReexecEnvvar+"="+os.Args[0])
cmd.Env = appendPluginResourceAttributesEnvvar(cmd.Env, rootcmd, plugin)

return cmd, nil
Expand Down

0 comments on commit 5ccb484

Please sign in to comment.