1
1
mirror of https://github.com/walles/moar.git synced 2024-07-07 08:36:29 +03:00

Fix executability check on Windows

This commit is contained in:
Johan Walles 2024-06-29 08:36:13 +02:00
parent a5317483e8
commit 2e13403096
2 changed files with 13 additions and 5 deletions

View File

@ -5,6 +5,7 @@ import (
"math"
"os"
"os/exec"
"runtime"
"strings"
log "github.com/sirupsen/logrus"
@ -111,13 +112,19 @@ func errUnlessExecutable(file string) error {
if err != nil {
return fmt.Errorf("Failed to stat %s: %w", file, err)
}
if stat.Mode()&0111 == 0 {
// Note that this check isn't perfect, it could still be executable but
// not by us. Corner case, let's just fail later in that case.
return fmt.Errorf("Not executable: %s", file)
if runtime.GOOS == "windows" && strings.HasSuffix(strings.ToLower(file), ".exe") {
log.Debug(".exe file on Windows, assuming executable: ", file)
return nil
}
return nil
if stat.Mode()&0111 != 0 {
// Note that this check isn't perfect, it could still be executable but
// not by us. Corner case, let's just fail later in that case.
return nil
}
return fmt.Errorf("Not executable: %s", file)
}
func handleEditingRequest(p *Pager) {

View File

@ -280,6 +280,7 @@ func printProblemsHeader() {
fmt.Fprintln(os.Stderr, "LANG :", os.Getenv("LANG"))
fmt.Fprintln(os.Stderr, "TERM :", os.Getenv("TERM"))
fmt.Fprintln(os.Stderr, "MOAR :", os.Getenv("MOAR"))
fmt.Fprintln(os.Stderr, "EDITOR :", os.Getenv("EDITOR"))
fmt.Fprintln(os.Stderr)
fmt.Fprintln(os.Stderr, "GOOS :", runtime.GOOS)
fmt.Fprintln(os.Stderr, "GOARCH :", runtime.GOARCH)