Skip to content

Commit b982833

Browse files
authored
Merge pull request #5027 from laurazard/run-hooks-reexec-env-var
hooks: set expected environment when executing
2 parents 78089c5 + 5011759 commit b982833

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cli-plugins/manager/plugin.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package manager
22

33
import (
44
"encoding/json"
5+
"os"
56
"os/exec"
67
"path/filepath"
78
"regexp"
@@ -113,7 +114,10 @@ func (p *Plugin) RunHook(cmdName string, flags map[string]string) ([]byte, error
113114
return nil, wrapAsPluginError(err, "failed to marshall hook data")
114115
}
115116

116-
hookCmdOutput, err := exec.Command(p.Path, p.Name, HookSubcommandName, string(hDataBytes)).Output()
117+
pCmd := exec.Command(p.Path, p.Name, HookSubcommandName, string(hDataBytes))
118+
pCmd.Env = os.Environ()
119+
pCmd.Env = append(pCmd.Env, ReexecEnvvar+"="+os.Args[0])
120+
hookCmdOutput, err := pCmd.Output()
117121
if err != nil {
118122
return nil, wrapAsPluginError(err, "failed to execute plugin hook subcommand")
119123
}

0 commit comments

Comments
 (0)