Fix WSL/Cygwin paths.
This commit is contained in:
parent
3d8e1d5f7e
commit
f14ffdef11
1 changed files with 25 additions and 7 deletions
|
@ -14,6 +14,7 @@ import (
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
@ -23,11 +24,9 @@ import (
|
||||||
"github.com/ncruces/zenity/internal/zenutil"
|
"github.com/ncruces/zenity/internal/zenutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const unspecified = "\x00"
|
||||||
unspecified = "\x00"
|
|
||||||
)
|
|
||||||
|
|
||||||
var tag = "v0.0.0"
|
var tag = ""
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// Application Options
|
// Application Options
|
||||||
|
@ -278,7 +277,7 @@ func setupFlags() {
|
||||||
func validateFlags() {
|
func validateFlags() {
|
||||||
var n int
|
var n int
|
||||||
if version {
|
if version {
|
||||||
fmt.Printf("zenity %s %s/%s\n", tag, runtime.GOOS, runtime.GOARCH)
|
fmt.Printf("zenity %s %s/%s\n", getVersion(), runtime.GOOS, runtime.GOARCH)
|
||||||
fmt.Println("https://github.com/ncruces/zenity")
|
fmt.Println("https://github.com/ncruces/zenity")
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
@ -538,9 +537,9 @@ func ingestPath(path string) string {
|
||||||
var args []string
|
var args []string
|
||||||
switch {
|
switch {
|
||||||
case wslpath:
|
case wslpath:
|
||||||
args = []string{"wsl", "wslpath", "-m"}
|
args = []string{"wsl", "wslpath", "-w"}
|
||||||
case cygpath:
|
case cygpath:
|
||||||
args = []string{"cygpath", "-C", "UTF8", "-m"}
|
args = []string{"cygpath", "-C", "UTF8", "-w"}
|
||||||
}
|
}
|
||||||
if args != nil {
|
if args != nil {
|
||||||
args = append(args, path)
|
args = append(args, path)
|
||||||
|
@ -616,3 +615,22 @@ func addFileFilter(s string) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getVersion() string {
|
||||||
|
if tag != "" {
|
||||||
|
return tag
|
||||||
|
}
|
||||||
|
|
||||||
|
rev := "unknown"
|
||||||
|
if info, ok := debug.ReadBuildInfo(); ok {
|
||||||
|
for _, kv := range info.Settings {
|
||||||
|
if kv.Key == "vcs.modified" && kv.Value == "true" {
|
||||||
|
return "custom"
|
||||||
|
}
|
||||||
|
if kv.Key == "vcs.revision" {
|
||||||
|
rev = kv.Value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rev
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue