debug
This commit is contained in:
parent
8a7fdf0f43
commit
f627fde186
1 changed files with 3 additions and 10 deletions
13
cmd/which.go
13
cmd/which.go
|
@ -17,25 +17,20 @@ type BasicOptions struct {
|
||||||
|
|
||||||
func Which(cmd string, options BasicOptions) (dir string, err error) {
|
func Which(cmd string, options BasicOptions) (dir string, err error) {
|
||||||
|
|
||||||
fmt.Println(options.Env)
|
|
||||||
fmt.Println(options.Sources)
|
|
||||||
|
|
||||||
var sourceCommand strings.Builder
|
var sourceCommand strings.Builder
|
||||||
for _, value := range options.Sources {
|
for _, value := range options.Sources {
|
||||||
sourceCommand.WriteString(fmt.Sprintf("source %s && ", value))
|
sourceCommand.WriteString(fmt.Sprintf("source %s && ", value))
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(cmd)
|
|
||||||
|
|
||||||
command := exec.Command("/bin/bash", "-c", "which", cmd)
|
command := exec.Command("/bin/bash", "-c", "which", cmd)
|
||||||
|
|
||||||
if options.Cwd != "" {
|
if options.Cwd != "" {
|
||||||
command.Dir = options.Cwd
|
command.Dir = options.Cwd
|
||||||
}
|
}
|
||||||
|
|
||||||
//for k, v := range options.Env {
|
for k, v := range options.Env {
|
||||||
// command.Env = append(command.Env, fmt.Sprintf("%s=%s", k, v))
|
command.Env = append(command.Env, fmt.Sprintf("%s=%s", k, v))
|
||||||
//}
|
}
|
||||||
|
|
||||||
outputBytes, err := command.Output()
|
outputBytes, err := command.Output()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -49,8 +44,6 @@ func Which(cmd string, options BasicOptions) (dir string, err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(string(outputBytes))
|
|
||||||
|
|
||||||
return strings.Trim(string(outputBytes), "\n"), nil
|
return strings.Trim(string(outputBytes), "\n"), nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue