Don't use $HOME on Windows; use $USERPROFILE instead.
Merge changes between Linux/Windows versions.