mirror of
https://github.com/walles/moar.git
synced 2024-10-05 16:07:54 +03:00
Fix executability check on Windows
This commit is contained in:
parent
a5317483e8
commit
2e13403096
@ -5,6 +5,7 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
@ -111,13 +112,19 @@ func errUnlessExecutable(file string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to stat %s: %w", file, err)
|
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
|
if runtime.GOOS == "windows" && strings.HasSuffix(strings.ToLower(file), ".exe") {
|
||||||
// not by us. Corner case, let's just fail later in that case.
|
log.Debug(".exe file on Windows, assuming executable: ", file)
|
||||||
return fmt.Errorf("Not executable: %s", 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) {
|
func handleEditingRequest(p *Pager) {
|
||||||
|
1
moar.go
1
moar.go
@ -280,6 +280,7 @@ func printProblemsHeader() {
|
|||||||
fmt.Fprintln(os.Stderr, "LANG :", os.Getenv("LANG"))
|
fmt.Fprintln(os.Stderr, "LANG :", os.Getenv("LANG"))
|
||||||
fmt.Fprintln(os.Stderr, "TERM :", os.Getenv("TERM"))
|
fmt.Fprintln(os.Stderr, "TERM :", os.Getenv("TERM"))
|
||||||
fmt.Fprintln(os.Stderr, "MOAR :", os.Getenv("MOAR"))
|
fmt.Fprintln(os.Stderr, "MOAR :", os.Getenv("MOAR"))
|
||||||
|
fmt.Fprintln(os.Stderr, "EDITOR :", os.Getenv("EDITOR"))
|
||||||
fmt.Fprintln(os.Stderr)
|
fmt.Fprintln(os.Stderr)
|
||||||
fmt.Fprintln(os.Stderr, "GOOS :", runtime.GOOS)
|
fmt.Fprintln(os.Stderr, "GOOS :", runtime.GOOS)
|
||||||
fmt.Fprintln(os.Stderr, "GOARCH :", runtime.GOARCH)
|
fmt.Fprintln(os.Stderr, "GOARCH :", runtime.GOARCH)
|
||||||
|
Loading…
Reference in New Issue
Block a user