Skip to content

fix: is_wsl() matches all Linux kernels, not just WSL#123

Open
gavmor wants to merge 1 commit into
tmux-plugins:masterfrom
gavmor:fix/is_wsl-linux-detection
Open

fix: is_wsl() matches all Linux kernels, not just WSL#123
gavmor wants to merge 1 commit into
tmux-plugins:masterfrom
gavmor:fix/is_wsl-linux-detection

Conversation

@gavmor
Copy link
Copy Markdown

@gavmor gavmor commented May 6, 2026

Summary

  • is_wsl() in helpers.sh checks /proc/version for "Linux" OR "Microsoft" — but every Linux kernel starts with "Linux version ...", so is_wsl() returns true on all Linux hosts, not just WSL
  • This causes battery_remain.sh to take the WSL sysfs code path (reading charge_full/charge_now) instead of falling through to upower/acpi
  • On systems without acpi installed, the WSL path silently fails with a division-by-zero error because modern kernels use energy_full/energy_now instead of charge_full/charge_now
  • WSL kernels contain "Microsoft" or "microsoft" — native Linux kernels do not — so removing the "Linux" check correctly distinguishes them

Test plan

  • is_wsl returns true on WSL (/proc/version contains "Microsoft")
  • is_wsl returns false on native Linux (/proc/version contains "Linux" but not "Microsoft")
  • battery_remain correctly uses upower (or acpi/pmset/apm) on native Linux
  • battery_remain still uses WSL sysfs path on actual WSL

💘 Generated with Crush

/proc/version contains "Linux" on every Linux system (e.g. "Linux version
6.17.0-23-generic ..."). The `|| "$version" == *"Linux"*` condition causes
is_wsl() to return true on non-WSL hosts, which makes battery_remain.sh
take the WSL sysfs code path instead of falling through to upower/acpi.

On systems without acpi installed, the WSL path fails with division-by-zero
because /sys/class/power_supply/*/charge_full and charge_now don't exist on
modern kernels that use energy_full/energy_now instead.

Fix: remove the "Linux" check — only "Microsoft"/"microsoft" distinguishes
a WSL kernel from a native Linux kernel.

💘 Generated with Crush

Assisted-by: DeepSeek V4 Pro via Crush <crush@charm.land>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant