Skip to content

Commit

Permalink
fix: detect wsl using env variable
Browse files Browse the repository at this point in the history
  • Loading branch information
lnu committed Feb 15, 2021
1 parent 73eab4a commit e0e2962
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ func (e *engine) render() {
}

cwd := e.env.getcwd()

// temp to fix 3.89 issue and add wsl support
if e.env.isWsl() {
// transform path
cwd, _ = e.env.runCommand("wslpath", "-m", cwd)
Expand Down
8 changes: 5 additions & 3 deletions src/environment_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package main
import (
"errors"
"os"
"strings"
)

func (env *environment) isRunningAsRoot() bool {
Expand All @@ -21,6 +20,9 @@ func (env *environment) getWindowTitle(imageName, windowTitleRegex string) (stri
}

func (env *environment) isWsl() bool {
version := env.getFileContent("/proc/version")
return strings.Contains(version, "microsoft")
// one way to check
// version := env.getFileContent("/proc/version")
// return strings.Contains(version, "microsoft")
// using env variable
return env.getenv("WSL_DISTRO_NAME") != ""
}

0 comments on commit e0e2962

Please sign in to comment.