handle symlinks in shell completion

This commit is contained in:
Gokcehan 2016-08-16 23:17:19 +03:00
parent 4c5e5584ed
commit c05a33a751

View File

@ -4,6 +4,7 @@ import (
"io/ioutil" "io/ioutil"
"log" "log"
"os" "os"
"path"
"strings" "strings"
) )
@ -68,6 +69,11 @@ func matchExec(s string) string {
for _, f := range fi { for _, f := range fi {
if strings.HasPrefix(f.Name(), s) { if strings.HasPrefix(f.Name(), s) {
f, err = os.Stat(path.Join(p, f.Name()))
if err != nil {
log.Print(err)
}
if !f.Mode().IsRegular() || f.Mode()&0111 == 0 { if !f.Mode().IsRegular() || f.Mode()&0111 == 0 {
continue continue
} }