summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraritmos <52433836+aritmos@users.noreply.github.com>2024-03-22 11:56:06 +0100
committeraritmos <52433836+aritmos@users.noreply.github.com>2024-03-22 13:42:15 +0100
commit68495ea0ee0ef26863f661cbe8c1f124e7ef1efd (patch)
tree0b2b7f0b69972d2407775114e5592487429c3860
parent53363b761cb183bf26fdd19928f31ee16bdefdcd (diff)
Fix container detection
Running WSL without a container would be treated as native linux, causing problems at it would then attempt to use `xdg-open`. This was caused by `isContainer()` always returning true due to some dubious conditionals. These have been removed. The env-var check seems to not be used by lazygit, nor any common containers, and therefore appears to only exist to manually tell lazygit to behave as if it were inside of a container. This functionality has been kept, but the env-var has been changed to be all uppercaps as to comply with the POSIX standard. Fixes #2757 Bug introduced in 4d78d76
-rw-r--r--pkg/config/config_linux.go11
1 files changed, 2 insertions, 9 deletions
diff --git a/pkg/config/config_linux.go b/pkg/config/config_linux.go
index 892e58de3..8aaea4576 100644
--- a/pkg/config/config_linux.go
+++ b/pkg/config/config_linux.go
@@ -12,16 +12,9 @@ func isWSL() bool {
func isContainer() bool {
data, err := os.ReadFile("/proc/1/cgroup")
-
- if strings.Contains(string(data), "docker") ||
+ return err == nil && (strings.Contains(string(data), "docker") ||
strings.Contains(string(data), "/lxc/") ||
- []string{string(data)}[0] != "systemd" &&
- []string{string(data)}[0] != "init" ||
- os.Getenv("container") != "" {
- return err == nil && true
- }
-
- return err == nil && false
+ os.Getenv("CONTAINER") != "")
}
// GetPlatformDefaultConfig gets the defaults for the platform