github.com/u-root/u-root@v7.0.1-0.20200915234505-ad7babab0a8e+incompatible/cmds/core/elvish/util/search.go (about) 1 package util 2 3 import ( 4 "os" 5 "path/filepath" 6 "strings" 7 ) 8 9 // DontSearch determines whether the path to an external command should be 10 // taken literally and not searched. 11 func DontSearch(exe string) bool { 12 return exe == ".." || strings.ContainsRune(exe, filepath.Separator) 13 } 14 15 // IsExecutable determines whether path refers to an executable file. 16 func IsExecutable(path string) bool { 17 fi, err := os.Stat(path) 18 if err != nil { 19 return false 20 } 21 fm := fi.Mode() 22 return !fm.IsDir() && (fm&0111 != 0) 23 }