Pretty straightforward, the usual places to figure out the OS you\'re on seem to be identical to plain Ubuntu on Ubuntu for Windows. For example uname -a is ide
I needed to test for macOS in addition to Windows Subsystem for Linux 2.
This is the simplest thing working for us.
if [[ $OSTYPE == darwin* ]]; then
# macOS
elif [[ "$(
NOTE: The if order matters. On macOS you get this error when looking at proc/version.
/proc/version: No such file or directory
hat-tip @Niklas Holm and @Marc Cornellà in the top answer's comments for aiming me toward the correct WSL check.