diff --git a/action.go b/action.go index 1d0ddbf7f..9c6880ecd 100644 --- a/action.go +++ b/action.go @@ -40,12 +40,11 @@ type Context struct { } // Setenv sets the value of the environment variable named by the key. -func (c Context) Setenv(key, value string) Context { +func (c *Context) Setenv(key, value string) { if c.Env == nil { c.Env = []string{} } c.Env = append(c.Env, fmt.Sprintf("%v=%v", key, value)) - return c } // Cache cashes values of a CompletionCallback for given duration and keys diff --git a/defaultActions_test.go b/defaultActions_test.go index debe766d3..c834d28da 100644 --- a/defaultActions_test.go +++ b/defaultActions_test.go @@ -51,6 +51,8 @@ func TestActionExecCommandEnv(t *testing.T) { return ActionValues() }).Invoke(Context{}) + c := Context{} + c.Setenv("carapace_TestActionExecCommand", "test") ActionExecCommand("env")(func(output []byte) Action { lines := strings.Split(string(output), "\n") for _, line := range lines { @@ -60,5 +62,5 @@ func TestActionExecCommandEnv(t *testing.T) { } t.Error("should contain env carapace_TestActionExecCommand=test") return ActionValues() - }).Invoke(Context{}.Setenv("carapace_TestActionExecCommand", "test")) + }).Invoke(c) }