elvish/eval/search.go

25 lines
611 B
Go
Raw Normal View History

package eval
import (
"fmt"
"github.com/elves/elvish/parse"
"github.com/elves/elvish/util"
)
// Search tries to resolve an external command and return the full (possibly
// relative) path.
func (ev *Evaler) Search(exe string) (string, error) {
path, err := util.Search(ev.searchPaths(), exe)
if err != nil {
return "", fmt.Errorf("search %s: %s", parse.Quote(exe), err.Error())
}
return path, nil
}
2016-01-26 07:26:49 +08:00
// AllExecutables writes the names of all executable files in the search path
// to a channel.
func (ev *Evaler) AllExecutables(names chan<- string) {
util.AllExecutables(ev.searchPaths(), names)
}