mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 09:57:51 +08:00
19 lines
405 B
Go
19 lines
405 B
Go
package eval
|
|
|
|
import "io/ioutil"
|
|
|
|
// EachExternal calls f for each name that can resolve to an external
|
|
// command.
|
|
// TODO(xiaq): Windows support
|
|
func (ev *Evaler) EachExternal(f func(string)) {
|
|
for _, dir := range ev.searchPaths() {
|
|
// XXX Ignore error
|
|
infos, _ := ioutil.ReadDir(dir)
|
|
for _, info := range infos {
|
|
if !info.IsDir() && (info.Mode()&0111 != 0) {
|
|
f(info.Name())
|
|
}
|
|
}
|
|
}
|
|
}
|