зеркало из https://github.com/Azure/draft-classic.git
plugin: expand command after splitting string
In case of spaces in $DRAFT_PLUGIN_DIR, splitting the Command with spaces caused main to be computed incorrectly, containing the executable path only partially up to the first space.
This commit is contained in:
Родитель
cfed0d4892
Коммит
71bcdf6100
|
@ -97,7 +97,7 @@ type Plugin struct {
|
|||
//
|
||||
// The result is suitable to pass to exec.Command.
|
||||
func (p *Plugin) PrepareCommand(extraArgs []string) (string, []string) {
|
||||
parts := strings.Split(os.ExpandEnv(p.Metadata.Command), " ")
|
||||
parts := strings.Split(p.Metadata.Command, " ")
|
||||
main := parts[0]
|
||||
baseArgs := []string{}
|
||||
if len(parts) > 1 {
|
||||
|
@ -106,7 +106,13 @@ func (p *Plugin) PrepareCommand(extraArgs []string) (string, []string) {
|
|||
if !p.Metadata.IgnoreFlags {
|
||||
baseArgs = append(baseArgs, extraArgs...)
|
||||
}
|
||||
return main, baseArgs
|
||||
|
||||
expandedArgs := make([]string, 0, len(baseArgs))
|
||||
for _, baseArg := range baseArgs {
|
||||
expandedArgs = append(expandedArgs, os.ExpandEnv(baseArg))
|
||||
}
|
||||
|
||||
return os.ExpandEnv(main), expandedArgs
|
||||
}
|
||||
|
||||
// LoadDir loads a plugin from the given directory.
|
||||
|
|
Загрузка…
Ссылка в новой задаче