This is my foo.bat file:
if 0==0 (
set foo=abc
echo "%foo%"
)
Windows (10 Pro Build 19043)
Call it with cmd.exe /C foo.bat, it prints "abc".
WSL (2, Ubuntu-20.04)
Call it with cmd.exe /C foo.bat it prints "".
Things I checked
- SETLOCAL EnableDelayedExpansion changes nothing
- cmd.exe in WSL is
/mnt/c/Windows/system32/cmd.exe - when you remove the enclosing if, it works